RFR: 8361099: Shenandoah: Improve heap lock contention by using CAS for memory allocation [v14]

Xiaolong Peng xpeng at openjdk.org
Wed Dec 3 01:21:56 UTC 2025


On Tue, 2 Dec 2025 22:10:34 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 255 commits:
>> 
>>  - Add missing header for ShenandoahFreeSetPartitionId
>>  - Declare ShenandoahFreeSetPartitionId as enum instead of enum class
>>  - Fix a typo
>>  - Remove unnecessary `enum class ShenandoahFreeSetPartitionId : uint8_t` in shenandoahAllocator.php
>>  - Make ShenandoahAllocator as template class to make compiled code more efficient for each alloc partition
>>  - Port the fix of JDK-8372566
>>  - Merge branch 'master' into cas-alloc-1
>>  - Merge remote-tracking branch 'origin/master' into cas-alloc-1
>>  - Remove junk code
>>  - Remove unnecessary change and tidy up
>>  - ... and 245 more: https://git.openjdk.org/jdk/compare/79e99bb0...7980c039
>
> src/hotspot/share/gc/shenandoah/shenandoahAllocator.cpp line 158:
> 
>> 156:   if (r != nullptr) {
>> 157:     bool ready_for_retire = false;
>> 158:     obj = atomic_allocate_in(r, false, req, in_new_region, ready_for_retire);
> 
> Not sure why we use atomic_allocate_in() here.  We hold the heap lock so we don't need to use atomic operations.  
> We should clarify with comments.

It is not really necessary to `atomic_allocate_in` here, but I wanted reuse some of the codes in atomic_allocate_in, we can discuss this later, I can change it back to non-atomic version.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26171#discussion_r2583304908


More information about the shenandoah-dev mailing list