RFR: 8370325: G1: Only one source of GC operations during object allocation [v3]

Albert Mingkun Yang ayang at openjdk.org
Wed Oct 22 13:00:04 UTC 2025


On Wed, 22 Oct 2025 10:42:17 GMT, Thomas Schatzl <tschatzl at openjdk.org> wrote:

>> Hi all,
>> 
>>   please review this change to the object allocation path to only allow direct allocation after failing TLAB allocation doing GCs.
>> 
>> Currently, when allocating an object, G1 (or actually any collector) first allocates from TLABs, then allocates from outside TLABs.
>> 
>> When G1 can't find space for a TLAB in the current region, it passes on control to `G1CollectedHeap::attempt_allocation[_slow]` that first tries to allocate that memory using a new region, or if that fails, do a GC. Potential allocation outside TLABs that would follow TLAB-allocation does the same.
>> 
>> G1's behavior to do a GC during failed TLAB allocation is problematic for the `UseGCOverheadLimit` functionality (https://bugs.openjdk.org/browse/JDK-8212084): if the GC overhead limit triggers in a TLAB allocation, it returns `null` for that TLAB allocation.
>> Control will be passed to outside-tlab allocation as described above. Since the garbage collections for TLAB allocations did free some memory (but because of exceeded gc overhead we returned null for the TLAB allocation), that allocation/collection for this outside-tlab allocation will succeed and return non-`null` to the mutator, effectively swallowing the information that GC overhead has been exceeded.
>> 
>> I split this out from the `UseGCOverheadLimit` change because I thought it is somewhat standalone, but I can merge it.
>> 
>> Testing: tier1-5, performance neutral after some tests
>> 
>> Hth,
>>   Thomas
>
> Thomas Schatzl has updated the pull request incrementally with one additional commit since the last revision:
> 
>   * more parameter name changes, walulyai review

Maybe the title can be revised a bit -- sth like "G1: Disallow GC for TLAB allocation".

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

Marked as reviewed by ayang (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/27932#pullrequestreview-3365675897


More information about the hotspot-gc-dev mailing list