RFR: 8357445: G1: Time-Based Heap Uncommit During Idle Periods [v7]
Monica Beckwith
mbeckwit at openjdk.org
Tue Oct 7 23:18:19 UTC 2025
On Tue, 2 Sep 2025 10:17:33 GMT, Thomas Schatzl <tschatzl at openjdk.org> wrote:
> Also, garbage collections and the `VM_G1ShrinkHeap` operation need to reset the timestamp for all (free) regions too. Otherwise the mechanism will try to uncommit the wrong amount of regions, similar to the issue I described in `VM_G1ShrinkHeap`.
>
> E.g. Regions A, B, C are free for a long time, GC happens that keeps A, B, C for various reasons, now idle-evaluation happens, and A, B, C are determined idle in addition to the other regions if their timestamp is not reset. So the idle uncommit will free too many regions.
Makes sense. I have added activity tracking in region transitions:
void G1HeapRegion::set_free() {
if (!is_free()) {
report_region_type_change(G1HeapRegionTraceType::Free);
record_activity(); // Updates timestamp when region becomes free
}
_type.set_free();
}
Hence, during GC operations like shown below the timestamp will be updated:
bool RebuildRegionSetsClosure::do_heap_region(G1HeapRegion* r) {
if (r->is_empty()) {
r->set_free(); // This updates timestamps for regions processed during GC
_hrm->insert_into_free_list(r);
}
// ...
}
-------------
PR Comment: https://git.openjdk.org/jdk/pull/26240#issuecomment-3379007364
More information about the hotspot-dev
mailing list