RFR: 8293503: gc/metaspace/TestMetaspacePerfCounters.java#Epsilon-64 failed assertGreaterThanOrEqual: expected MMM >= NNN [v2]
Leo Korinth
lkorinth at openjdk.org
Wed Sep 14 13:24:37 UTC 2022
On Wed, 14 Sep 2022 09:15:54 GMT, Thomas Schatzl <tschatzl at openjdk.org> wrote:
>> Hi all,
>>
>> can I have reviews for this change that workarounds some epsilon gc specific behavior in the gc/metaspace/TestMetaspacePerfCounters test?
>>
>> The test gathers statistics about metaspace to check one by one:
>>
>> // The perf counter values are updated during GC and to be able to
>> // do the assertions below we need to ensure that the values are from
>> // the same GC cycle.
>> do {
>> gcCountBefore = currentGCCount();
>>
>> minCapacity = getMinCapacity(ns);
>> maxCapacity = getMaxCapacity(ns);
>> capacity = getCapacity(ns);
>> used = getUsed(ns);
>>
>> [...]
>>
>> For Epsilon GC the assumption stated in the comment in the code does not hold (and in general, it seems more because of knowledge about Hotspot than actual specification) - Epsilon also updates the statistics every X TLAB refills without a pause. Without these updates at TLAB refill, Epsilon would mostly always never update these (it does not do any GC by itself, only out-of-metaspace GC actually performs one).
>>
>> The problem then is that if there is such an update between getCapacity() and getUsed(), used can be larger than capacity gathered before as both may have changed at the second call. It also assumes that there is sufficient memory visibility related synchronization between these calls.
>>
>> There is no way to get multiple performance counter values atomically as e.g. in the MemoryMXBean API, so some inconsistency is probably expected.
>>
>> So the suggested fix here is to get two snapshots of the values, separated by a memory barrier and only continue if both snapshots are equal.
>>
>> Testing: running the test for 1000 times without issue, fails 10 times or so without this patch
>>
>> Thanks,
>> Thomas
>
> Thomas Schatzl has updated the pull request incrementally with one additional commit since the last revision:
>
> lkorinth suggestion
test/hotspot/jtreg/gc/metaspace/TestMetaspacePerfCounters.java line 245:
> 243: PerfCounterSnapshot snap2 = new PerfCounterSnapshot();
> 244:
> 245: final int MaxAttempts = 10;
This should be used or removed as well, right?
-------------
PR: https://git.openjdk.org/jdk/pull/10239
More information about the hotspot-gc-dev
mailing list