RFR: 8274178: G1: Occupancy value in IHOP logging and JFR event is inaccurate [v2]

Albert Mingkun Yang ayang at openjdk.org
Tue Nov 11 11:15:12 UTC 2025


On Fri, 7 Nov 2025 14:32:38 GMT, Thomas Schatzl <tschatzl at openjdk.org> wrote:

>> Hi all,
>> 
>>   please review this change that modifies heap occupancy reporting for IHOP to use the actual occupancy value the IHOP calculation actually uses.
>> 
>> I.e. previously IHOP logging used to report `G1CollectedHeap::used()` as occupancy (which is correct at a general level), but for IHOP/marking that value is not interesting, but the "occupancy" value used for comparing against the current heap occupancy threshold.
>> 
>> Testing: tier1-3, GHA
>> 
>> Thomas
>
> Thomas Schatzl has updated the pull request incrementally with one additional commit since the last revision:
> 
>   * ayang review, missing conversion of word size to byte size

> previously IHOP logging used to report G1CollectedHeap::used() as occupancy (which is correct at a general level)

Instead of passing the pending-allocation-size as an arg, what do you think of adding a new API, `used_with_pending_allocation`, which is used when pending-alloc is also interesting to the caller?

src/hotspot/share/gc/g1/g1HeapSizingPolicy.cpp line 372:

> 370:   // include the waste in the following calculations.
> 371:   const size_t capacity_after_gc = _g1h->capacity();
> 372:   const size_t used_after_gc = capacity_after_gc +

It took me a while to understand this calculation; I wonder if this can broken down into two pieces, sth like:


const size_t current_used_after_gc = capacity - unused - eden;
// Add pending allocation;
const size_t used_after_gc = existing_used + _g1h->allocation_used_bytes(allocation_word_size);

-------------

PR Review: https://git.openjdk.org/jdk/pull/28175#pullrequestreview-3447491820
PR Review Comment: https://git.openjdk.org/jdk/pull/28175#discussion_r2513784636


More information about the hotspot-gc-dev mailing list