RFR: 8357445: G1: Time-Based Heap Uncommit During Idle Periods [v7]
Monica Beckwith
mbeckwit at openjdk.org
Tue Oct 7 20:40:31 UTC 2025
On Tue, 2 Sep 2025 10:15:13 GMT, Thomas Schatzl <tschatzl at openjdk.org> wrote:
>> I also do not think this mechanism should ever uncommit the free regions reserved for the current young gen (without GC/recalculating the needed young gen) and potentially the survivor/old regions. There does not seem to be a limit here.
>>
>> Otherwise the next GC (or just continuing work) will be riddled with in-pause commits. Or it will probably do a premature GC, I did not check.
>>
>> Maybe this change should only madvise these regions as MADV_DONTNEED? (Not sure it does anything though).
>
> Also there should potentially be a buffer for humongous object allocation, otherwise they will cause immediate garbage collections.
> I.e.: err on the conservative side.
I have added multiple checks now:
GC Pressure:
// Back off during allocation pressure - only evaluate when truly idle
if (_analytics != nullptr) {
double gc_time_ratio = _analytics->short_term_pause_time_ratio();
if (gc_time_ratio > 0.05) { // 5% GC time still indicates pressure
log_trace(gc, sizing)("Uncommit evaluation: skipping due to high GC overhead (%1.1f%%)",
gc_time_ratio * 100.0);
return 0;
}
}
Reserve Calculation:
// Use G1's existing reserve calculation plus young generation requirements
// G1 maintains a reserve (default 10% via G1ReservePercent) for allocation needs
size_t young_gen_regions = _g1h->policy()->young_list_target_length();
size_t total_regions = _g1h->max_num_regions();
size_t g1_reserve_regions = (size_t)ceil((double)total_regions * G1ReservePercent / 100.0);
// Total regions we must keep available = young gen + G1's standard reserve
size_t reserved_regions = young_gen_regions + g1_reserve_regions;
Conservative Limits:
// Be very conservative about how much to uncommit at once
// Never uncommit more than a small fraction of committed regions
size_t max_uncommit_at_once = MAX2((size_t)G1MinRegionsToUncommit, committed_regions / 8);
size_t regions_to_uncommit = MIN3(available_for_uncommit, max_inactive_regions, max_uncommit_at_once);
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26240#discussion_r2411798199
More information about the hotspot-dev
mailing list