RFR: 8311639: Replace currentTimeMillis() with nanoTime() in jtreg/gc
Leo Korinth
lkorinth at openjdk.org
Fri Aug 18 09:09:29 UTC 2023
On Fri, 18 Aug 2023 08:56:01 GMT, Leo Korinth <lkorinth at openjdk.org> wrote:
>> test/hotspot/jtreg/gc/stress/systemgc/TestSystemGC.java line 80:
>>
>>> 78: public void run() {
>>> 79: while (!shouldExit()) {
>>> 80: String prefix = "long" + (System.nanoTime() % 10000); // limit to 4 digits after changing from milliseconds to nanoseconds, else the key will use more memory
>>
>> Is this used to calculate elapsed time? If not, I think using `currentTimeMillis` is fine.
>
> It is not to calculate elapsed time. It is to create a unique(ish) key for a hash table. The new code does not guarantee a unique value, but then neither did the old.
I could possibly add some characters to the key if that is what bothers you. I could of course also use `currentTimeMillis` as it is nothing wrong with it. But I would prefer removing `currentTimeMillis` in all gc testing.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/15331#discussion_r1298206509
More information about the hotspot-gc-dev
mailing list