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

Xiaolong Peng xpeng at openjdk.org
Tue Dec 9 18:48:35 UTC 2025


On Tue, 2 Dec 2025 22:04:06 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 155:
> 
>> 153:   size_t min_free_words = req.is_lab_alloc() ? req.min_size() : req.size();
>> 154:   ShenandoahHeapRegion* r = _free_set->find_heap_region_for_allocation(ALLOC_PARTITION, min_free_words, req.is_lab_alloc(), in_new_region);
>> 155:   // The region returned by find_heap_region_for_allocation must have sufficient free space for the allocation it if it is not nullptr
> 
> comment has an extra "it"

fixed.

> src/hotspot/share/gc/shenandoah/shenandoahAllocator.hpp line 69:
> 
>> 67: 
>> 68:   // Attempt to allocate in shared alloc regions, the allocation attempt is done with atomic operation w/o
>> 69:   // holding heap lock.
> 
> I would rewrite comment:
> // Attempt to allocate in a shared alloc region using atomic operation without holding the heap lock.
> // Returns nullptr and overwrites regions_ready_for_refresh with the number of shared alloc regions that are ready
> // to be retired if it is unable to satisfy the allocation request from the existing shared alloc regions.

Thanks, I have updated the the comments as you suggested.

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

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


More information about the hotspot-gc-dev mailing list