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 _atomic_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 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 replenished 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
 - [ ] Regular CI pipeline


---------
- [x] I confirm that I make this contribution in accordance with the [OpenJDK 
Interim AI Policy](https://openjdk.org/legal/ai).

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

Commit messages:
 - 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
 - Set default of ShenandoahCollectorAllocRegions to 1
 - Merge branch 'openjdk:master' into shenandoah-allocator-cas-single-top
 - Merge branch 'openjdk:master' into shenandoah-allocator-cas-single-top
 - ... and 28 more: https://git.openjdk.org/jdk/compare/291bc242...4d7d03ad

Changes: https://git.openjdk.org/jdk/pull/33781/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=33781&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8361099
  Stats: 2052 lines in 39 files changed: 1733 ins; 140 del; 179 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

Reply via email to