RFR: 8318709: Improve System.nanoTime performance on Windows

David Holmes dholmes at openjdk.org
Thu Oct 26 07:00:34 UTC 2023


On Thu, 26 Oct 2023 06:56:47 GMT, David Holmes <dholmes 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.
>
> src/hotspot/os/windows/os_windows.cpp line 804:
> 
>> 802: static jlong initial_performance_count;
>> 803: static jlong performance_frequency;
>> 804: static double counts_per_nano; // NANOSECS_PER_SEC / performance_frequency
> 
> Doesn't that calculate nanos_per_count?

Which is what we want of course.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/16336#discussion_r1372674518


More information about the hotspot-runtime-dev mailing list