> This introduces a lock-free CAS-based allocation path for Shenandoah's > mutator/collector/old-collector partitions, replacing (or supplementing) the > heap-locked serial allocator on the fast path. > > Each ShenandoahPartitionAllocator maintains a small stripe of cached "alloc > regions" per partition; threads map to a stripe slot and bump-allocate via > CAS on the region's _top without the heap lock. If the lock-free alloc > succeeds, it returns the object(before returning it may call > `try_replenish_after_alloc` to eagerly replenish alloc regions if there are > more than half of alloc regions are ready for retire). > > When all slots are exhausted or not having enough memory to satisfy the > request, a heap-locked slow path will: > 1. Replenish the slots which are ready for retire(free < min plab size) and > allocate from the new alloc region if possible; > 2. Directly find a region from the partition of free-set with enough memory > for the req, allocate in the region; > 3. For collector partitions, if the alloc req is till not satisfied, transfer > a region from mutator partition(`ShenandoahFreeSet::steal_from_mutator`) and > allocate from it. > > Performance wise, overall it is neutral in common cases because TLAB absorbs > most of contentions on heap lock, but with TLAB disabled we can see the big > difference in all benchmarks, also it unblocks the change eliminating > gclab/plab of mutator threads(https://github.com/openjdk/jdk/pull/33937). > > > > Test: > - [x] jtreg hotspot_gc_shenandoah > - [x] Regular CI pipeline > > > --------- > - [x] I confirm that I make this contribution in accordance with the [OpenJDK > Interim AI Policy](https://openjdk.org/legal/ai).
Xiaolong Peng has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 39 commits: - Merge branch 'master' into shenandoah-allocator-cas-single-top - Apply TTAS in try_lock - Try replenish alloc regions after alloc - Shenandoah: Add try_lock method - Clean up code comments - Replenish alloc regions in a single pass with slot and install callbacks - Drop the CPU-count and heap-size derivation of the alloc region stripe counts - Merge branch 'master' into shenandoah-allocator-cas-single-top # Conflicts: # src/hotspot/share/gc/shenandoah/shenandoahArguments.cpp # src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.cpp # src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.hpp # src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.inline.hpp - Set default of ShenandoahCollectorAllocRegions to 1 - Merge branch 'openjdk:master' into shenandoah-allocator-cas-single-top - ... and 29 more: https://git.openjdk.org/jdk/compare/f3821cd9...b0fa2f56 ------------- Changes: https://git.openjdk.org/jdk/pull/33781/files Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=33781&range=01 Stats: 2048 lines in 38 files changed: 1731 ins; 140 del; 177 mod Patch: https://git.openjdk.org/jdk/pull/33781.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/33781/head:pull/33781 PR: https://git.openjdk.org/jdk/pull/33781
