RFR: 8318709: Improve System.nanoTime performance on Windows

David Holmes dholmes at openjdk.org
Wed Oct 25 22:08:10 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.

Looking at:

https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-large_integer-r1

It seems the QuadPart needs native 64-bit compiler support, which I'm unclear is available when building for 32-bit Windows (which IIRC is a deprecated port but still present in this release). Also the web page indicates it is only available from Windows 10, which doesn't make a lot of sense.

To be honest I am struggling to understand how LARGE_INTEGER gets used by QPC/QPF as it is a union, so we have to know which member QPC/QPF sets, so we can read back the correct member. Though I wonder if given endian-ness the layout of the structs simply coincides with that of a native 64-bit variable?

-------------

PR Review: https://git.openjdk.org/jdk/pull/16336#pullrequestreview-1698321816


More information about the hotspot-runtime-dev mailing list