RFR: 8311639: Replace currentTimeMillis() with nanoTime() in jtreg/gc
Stefan Karlsson
stefank at openjdk.org
Fri Aug 18 07:18:26 UTC 2023
On Thu, 17 Aug 2023 15:56:04 GMT, Leo Korinth <lkorinth at openjdk.org> wrote:
> I have removed usage of `currentTimeMillis()` in jtreg/gc as `currentTimeMillis()` is not monotonic. It is mostly changing from milliseconds to nanoseconds. In certain places, I have changed the code from something like `(instant1 < instant2)` to `(instant1 - instant2 < 0)` It might look like I am removing instant2 from both sides of the inequality and the result ought to be the same, but due to overflow arithmetic, the change should be better if nanoseconds where to overflow. I have also removed some loops where the loop is doing nothing except sleeping. I somewhat shortened the string in the key of a hash map because the nanosecond value made the string too long for the heap size.
>
> All tests within jtreg/gc passes.
Looks good. I'd also go with Albert's suggestion and keep timeout logging in TestSystemGC.
test/hotspot/jtreg/gc/stress/systemgc/TestSystemGC.java line 195:
> 193: }
> 194: long timeoutNanos = Integer.parseInt(args[0]) * 1_000_000_000L;
> 195: System.out.println("Running with timeout of " + timeoutNanos + "ns");
The precision here is in seconds. Maybe just leave this print out to be in ms?
-------------
Marked as reviewed by stefank (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/15331#pullrequestreview-1583987479
PR Review Comment: https://git.openjdk.org/jdk/pull/15331#discussion_r1298093911
More information about the hotspot-gc-dev
mailing list