RFR: 8361099: Shenandoah: Improve heap lock contention by using CAS for memory allocation [v20]
Xiaolong Peng
xpeng at openjdk.org
Thu Jan 8 19:42:13 UTC 2026
On Wed, 7 Jan 2026 00:03:15 GMT, Kelvin Nilsen <kdnilsen at openjdk.org> wrote:
>> Xiaolong Peng has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 265 commits:
>>
>> - Merge branch 'openjdk:master' into cas-alloc-1
>> - Fix build error after merging from tip
>> - Merge branch 'master' into cas-alloc-1
>> - Merge branch 'master' into cas-alloc-1
>> - Some comments updates as suggested in PR review
>> - Fix build failure after merge
>> - Expend promoted from ShenandoahOldCollectorAllocator
>> - Merge branch 'master' into cas-alloc-1
>> - Address PR comments
>> - Merge branch 'openjdk:master' into cas-alloc-1
>> - ... and 255 more: https://git.openjdk.org/jdk/compare/de81d389...cf13b7b5
>
> src/hotspot/share/gc/shenandoah/shenandoahAllocator.cpp line 423:
>
>> 421: _yield_to_safepoint = false;
>> 422: }
>> 423:
>
> I suppose ShenandoahCollectorAllocator::randomize_start_index() might be a no-op. On the other hand, it would probably be better to use a random index for ShenandoahCollectorAllocator as well. We don't want to hobble one GC worker more than the others just because its preferred start index happens to hold a retire-ready region.
The code you put comments on is ShenandoahOldCollectorAllocator, which delegate the allocation to ShenandoahFreeSet in the PR, 0u in passed to ShenandoahAllocator constructor is the number of shared alloc regions, which should be 0. I'll work on ShenandoahOldCollectorAllocator to make it support CAS as well.
The start index of ShenandoahCollectorAllocator is slightly different from ShenandoahMutatorAllocator, for GC worker we can always use `worker_id % _alloc_region_count`, but there is some corner cases we need to consider, e.g. Java thread may call into ShenandoahCollectorAllocator from load barrier code. Currently for non worker threads, the start index is always 0, I think this is the part we can change it to random.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26171#discussion_r2673640072
More information about the hotspot-gc-dev
mailing list