RFR: 8274178: G1: Occupancy value in IHOP logging and JFR event is inaccurate [v4]
Thomas Schatzl
tschatzl at openjdk.org
Thu Nov 13 10:04:23 UTC 2025
On Wed, 12 Nov 2025 18:50:17 GMT, Albert Mingkun Yang <ayang at openjdk.org> wrote:
>> Thomas Schatzl has updated the pull request incrementally with one additional commit since the last revision:
>>
>> * fix compilation on osx
>
> src/hotspot/share/gc/g1/g1CollectedHeap.hpp line 1035:
>
>> 1033: inline void old_set_remove(G1HeapRegion* hr);
>> 1034:
>> 1035: size_t non_young_occupancy_after_allocation(size_t allocation_word_size);
>
> I think the original term `capacity` is less misleading -- with `occupancy` one always need to ponder a bit, is it just used-bytes or is it used-bytes aligned-up by region?
To me something-capacity is always some kind of (lower or) upper threshold, i.e. what is possible (mostly related to regions too). (Like min or max capacity of a container or similar, or min/max of the heap).
This is a current actual value of something, so "occupancy" and "used" seemed more appropriate to me. Additionally, to me "used" in G1 is actual usage without fragmentation losses, while "occupancy" tends to be the latter (including fragmentation) if I want to make the distinction.
Since for IHOP only the usage with fragmentation losses matters - G1 can't allocate into the regions anyway, I selected occupancy here (and it does not take that last old gen alloc region into account which we can still allocate into, something else I was thinking about to fix).
E.g. "used" for a set of humongous regions would be more related to the size of the object inside while "occupancy" the total size of the regions that object is allocated into. Vs. capacity that would be more about bounds (which isn't relevant in the context of this example, but just for contrast).
So in my view the new name is better than the old.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/28175#discussion_r2522701779
More information about the hotspot-gc-dev
mailing list