RFR: 8370325: G1: Only one source of GC operations during object allocation [v2]
Thomas Schatzl
tschatzl at openjdk.org
Wed Oct 22 10:14:37 UTC 2025
> 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:
* fix comments, walulyai review
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/27932/files
- new: https://git.openjdk.org/jdk/pull/27932/files/d75147e3..83de6f25
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=27932&range=01
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=27932&range=00-01
Stats: 2 lines in 1 file changed: 0 ins; 0 del; 2 mod
Patch: https://git.openjdk.org/jdk/pull/27932.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/27932/head:pull/27932
PR: https://git.openjdk.org/jdk/pull/27932
More information about the hotspot-gc-dev
mailing list