[jdk17] RFR: 8268265: MutableSpaceUsedHelper::take_sample() hits assert(left >= right) failed: avoid overflow
Kim Barrett
kbarrett at openjdk.java.net
Thu Jun 17 18:45:27 UTC 2021
On Wed, 16 Jun 2021 09:31:00 GMT, Thomas Schatzl <tschatzl at openjdk.org> wrote:
>> Please review this change to PerfData-based heap usage reporting by SerialGC
>> and ParallelGC.
>>
>> For both of these collectors, the periodic heap usage sampling and reporting
>> by the Watcher thread involves sampling the difference between each space's
>> current allocation pointer and its base pointer. But the Watcher thread
>> runs during GC safepoints, which means that sampling may occasionally occur
>> while the GC is in the process of updating the space being sampled. This
>> can result in a sample with a bogus value or even an assertion failure after
>> JDK-8260046.
>>
>> Other collectors seem to avoid this by sampling and recording the heap usage
>> value at specific synchronous times rather than asynchronously by the
>> Watcher thread.
>>
>> There isn't a particularly good place for synchronous updates for ParallelGC
>> and SerialGC, so this change doesn't do so. Instead, it makes the existing
>> asynchronous updates safe from interference by an in-progress GC. This is
>> done by having the update done under the Heap_lock. Introducing a more
>> fine-grained lock has the same problem as doing synchronous updates. Rather
>> than possibly blocking the sampling Watcher thread for the duration of a GC,
>> it tries to lock the Heap_lock and skips sampling if it's not available.
>>
>> Testing:
>> mach5 tier1-3, 5, 7 (3,5,7 are where focused Serial and ParallelGC testing is done).
>
> Lgtm.
Thansk @tschatzl and @walulyai for reviews.
-------------
PR: https://git.openjdk.java.net/jdk17/pull/65
More information about the hotspot-gc-dev
mailing list