RFR: 8318709: Improve System.nanoTime performance on Windows
Daniel Jeliński
djelinski at openjdk.org
Thu Oct 26 06:26:30 UTC 2023
On Tue, 24 Oct 2023 08:23:01 GMT, Daniel Jeliński <djelinski at openjdk.org> wrote:
> - use LARGE_INTEGER.QuadPart instead of assembling the jlong from high/low parts
> - precalculate counts_per_nano to avoid costly floating-point division in counter to nanosecond conversion
>
> Benchmark before:
> SystemTime.nanoTime avgt 15 19,366 � 0,383 ns/op
>
> After:
> SystemTime.nanoTime avgt 15 15,812 � 0,385 ns/op
>
> Tier1-2 clean.
Visual Studio supports 64bit integer types even in 32 bit mode. In fact, the JDK requires a compiler with 64bit integer support - it's used in jlong typedef, for example.
I checked the typedef for LARGE_INTEGER in Windows SDK, and it looks exactly like the one on the MSDN page - no ifdefs to check if we are compiling in 64bit mode.
> Though I wonder if given endian-ness the layout of the structs simply coincides with that of a native 64-bit variable?
That's it exactly.
By the way, here's a nice article from Raymond Chen about this:
https://devblogs.microsoft.com/oldnewthing/20040825-00/?p=38053
-------------
PR Comment: https://git.openjdk.org/jdk/pull/16336#issuecomment-1780486149
More information about the hotspot-runtime-dev
mailing list