RFR: 8355756: G1HeapSizingPolicy::full_collection_resize_amount should consider allocation size

Ivan Walulya iwalulya at openjdk.org
Tue Apr 29 15:27:46 UTC 2025


On Tue, 29 Apr 2025 10:42:41 GMT, Thomas Schatzl <tschatzl at openjdk.org> wrote:

>> Hi,
>> 
>> Please review this change to account for pending allocations when deciding how much to shrink the heap after a full gc. Otherwise, we shrink the heap only to trigger an expansion to satisfy the allocation request that triggered the full gc.
>> 
>> Testing: Tier 1-3
>
> src/hotspot/share/gc/g1/g1HeapSizingPolicy.cpp line 239:
> 
>> 237:   // unnecessary shrinking that would be followed by an expand call to satisfy the
>> 238:   // allocation.
>> 239:   size_t allocation_bytes = allocation_word_size * HeapWordSize;
> 
> I think we should do better here for humongous allocations: afaict we get the actual object size passed here, but in reality g1 needs to allocate on a full region basis.
> I.e. for humongous objects, `allocation_word_size` should be padded.

At this point all computation is considering bytes, later in the shrink helper we align_down since the shrinking is done on a region basis. So except for documentation purposes, I don't think we need to do the padding here.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/24944#discussion_r2066819626


More information about the hotspot-gc-dev mailing list