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

Xiaolong Peng xpeng at openjdk.org
Thu Jan 22 19:47:21 UTC 2026


On Tue, 6 Jan 2026 23:59:32 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 353:
> 
>> 351:         if (!r->has_allocs()) {
>> 352:           log_debug(gc, alloc)("%sAllocator: Reverting heap region %li to FREE due to no alloc in the region",
>> 353:             _alloc_partition_name, r->index());
> 
> This code looks suspect to me.  Maybe it works as is only because we are currently doing this only immediately before rebuilding free set.  If that's the case, there should be some documentation and maybe even some asserts that confirm it is true.
> 
> When we release_alloc_regions(), we should be adjusting the range for the associated partitions.  The code that most closely resembles this functionality is in ShenandoahFreeSet::move_regions_from_collector_to_mutator().  This is the code that moves collector and old-collector partitions to the mutator partition after evacuation is done.

It could happen with CAS allocator, e.g. right before final mark, mutator refreshed alloc regions and reserved some empty regions w/o any allocations in them, then at final mark, GC thread will release alloc regions to prepare for free set rebuild.

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

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


More information about the hotspot-gc-dev mailing list