RFR: 8212084: G1: Implement UseGCOverheadLimit
Ivan Walulya
iwalulya at openjdk.org
Thu Oct 23 11:01:04 UTC 2025
On Thu, 23 Oct 2025 07:11:16 GMT, Thomas Schatzl <tschatzl at openjdk.org> wrote:
> Hi all,
>
> please review these changes to implement the `UseGCOverheadLimit` functionality for G1 (and make the implementation for Parallel GC have similar output).
>
> The `UseGCOverheadLimit` feature prematurely returns `null` from a GC if GC cpu usage limits and heap usage limits are met for some time. This is to avoid a VM limping along if garbage collection gets into an endless cycle of garbage collections or until a "real" OOME is thrown.
>
> What is important here is how this works (derived from the Parallel GC implementation):
>
> * check overheads at the end of the (initial) garbage collection (before upgrading) to see whether we are over the limits for a successive amount of GCs.
> * keep doing GCs without actually allocating memory for the allocation request to keep on measuring gc CPU usage. This is important for measuring the correct cpu usage in case of the application being able to free memory on the OOME.
>
> Testing: tier1-5 without any OOMEs due to this feature, test case
>
> Thanks,
> Thomas
Some suggestions
src/hotspot/share/gc/g1/g1CollectedHeap.cpp line 976:
> 974:
> 975: if (UseGCOverheadLimit) {
> 976: bool little_mutator_time = (_policy->analytics()->long_term_gc_time_ratio() * 100) >= GCTimeLimit;
Suggestion:
bool gc_time_over_limit = (_policy->analytics()->long_term_gc_time_ratio() * 100) >= GCTimeLimit;
src/hotspot/share/gc/g1/g1CollectedHeap.cpp line 978:
> 976: bool little_mutator_time = (_policy->analytics()->long_term_gc_time_ratio() * 100) >= GCTimeLimit;
> 977: double free_space_percent = percent_of(num_available_regions() * G1HeapRegion::GrainBytes, max_capacity());
> 978: bool little_free_space = free_space_percent < GCHeapFreeLimit;
Suggestion:
bool free_space_below_limit = free_space_percent < GCHeapFreeLimit;
src/hotspot/share/gc/g1/g1CollectedHeap.cpp line 1002:
> 1000: bool maximal_compaction,
> 1001: bool expect_null_mutator_alloc_region) {
> 1002: // Skip allocation if GC overhead has been exceeded to let the mutator run into
Suggestion:
// Skip allocation if GC overhead limit has been exceeded to let the mutator run into
-------------
PR Review: https://git.openjdk.org/jdk/pull/27950#pullrequestreview-3369333247
PR Review Comment: https://git.openjdk.org/jdk/pull/27950#discussion_r2454708066
PR Review Comment: https://git.openjdk.org/jdk/pull/27950#discussion_r2454710623
PR Review Comment: https://git.openjdk.org/jdk/pull/27950#discussion_r2454716115
More information about the hotspot-gc-dev
mailing list