RFR: 8365919: Replace currentTimeMillis with nanoTime in Stresser.java [v2]

Bernd duke at openjdk.org
Mon Aug 25 12:45:55 UTC 2025


On Mon, 25 Aug 2025 12:16:35 GMT, Thomas Schatzl <tschatzl at openjdk.org> wrote:

>> Albert Mingkun Yang has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains three additional commits since the last revision:
>> 
>>  - review
>>  - Merge branch 'master' into test-nano-time
>>  - test-nano-time
>
> test/hotspot/jtreg/vmTestbase/nsk/share/test/Stresser.java line 214:
> 
>> 212:         iterations = 0;
>> 213:         long stressTime = options.getTime();
>> 214:         startTime = System.nanoTime()/1000000;
> 
> If the reason for the change is to use `System.nanoTime()` instead of `System.currentTimeMillis()` because of monoticity, wouldn't it be simpler to add a helper that returns a millisecond value based on `System.nanoTime()` and call that one instead of `System.currentTimeMillis()` and keep everything else the same?
> 
> Inlining the `System.nanoTime() / 1000000` statement a few times seems bad. Having a helper function for this might allow to include a comment why `System.currentTimeMillis()` is not used too.

Or use nanoTime resolution throughout the calculations and only normalize on printout and when comparing with the deadline. Although nanoTime is here not used for its resolution, I find it quite unusual to see that /1_000_000 sprinkled around the start time recording.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26879#discussion_r2298000781


More information about the hotspot-gc-dev mailing list