RFR: 8293503: gc/metaspace/TestMetaspacePerfCounters.java#Epsilon-64 failed assertGreaterThanOrEqual: expected MMM >= NNN
Thomas Schatzl
tschatzl at openjdk.org
Tue Sep 13 11:57:31 UTC 2022
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
-------------
Commit messages:
- Replace constant by named constant
- Suggestion by kbarrett
- Initial commit
Changes: https://git.openjdk.org/jdk/pull/10239/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=10239&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8293503
Stats: 98 lines in 2 files changed: 45 ins; 39 del; 14 mod
Patch: https://git.openjdk.org/jdk/pull/10239.diff
Fetch: git fetch https://git.openjdk.org/jdk pull/10239/head:pull/10239
PR: https://git.openjdk.org/jdk/pull/10239
More information about the hotspot-gc-dev
mailing list