RFR: 8293503: gc/metaspace/TestMetaspacePerfCounters.java#Epsilon-64 failed assertGreaterThanOrEqual: expected MMM >= NNN

Thomas Schatzl tschatzl at openjdk.org
Wed Sep 14 08:27:36 UTC 2022


On Tue, 13 Sep 2022 13:39:57 GMT, Leo Korinth <lkorinth at openjdk.org> wrote:

>> test/hotspot/jtreg/gc/metaspace/TestMetaspacePerfCounters.java line 256:
>> 
>>> 254:         if (attempts == MaxAttempts) {
>>> 255:             throw new Exception("Failed to get stable reading of metaspace performance counters after " + MaxAttempts + " tries");
>>> 256:         }
>> 
>> I think we should remove the second test in the while clause, and instead move the `throw` statement (with if) into the loop. If we do that we get rid of one test, and it is more clear that `++attempts < MaxAttempts` matches `attempts == MaxAttempts`. If we do that, we can also move `MaxAttempts` into the loop, limiting the life time. If MaxAttempts is only used once, I also think it can be removed, but do keep it if you or Kim want it.
>
> or maybe use a for loop:
> 
> for (int attempts = 0; ; attempts++) {
>   snap1.get(ns);
>   VarHandle.fullFence();
>   snap2.get(ns);
>   if (snap1.equals(snap2)) {
>     break;
>   } else if (attempts >= 10) {
>     throw new Exception("Failed to get stable reading of metaspace performance counters after " + attempts + " tries");
>   }
> }
> 
> 
> (I do not know if it is correct or even compiles)

Since this seems quite an "eye of the beholder" situation, and I do not really care either way, I'll adopt your suggestion.

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

PR: https://git.openjdk.org/jdk/pull/10239



More information about the hotspot-gc-dev mailing list