RFR: 8361099: Shenandoah: Improve heap lock contention by using CAS for memory allocation [v20]
Xiaolong Peng
xpeng at openjdk.org
Mon Jan 12 21:19:49 UTC 2026
On Tue, 6 Jan 2026 21:30:09 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 233:
>
>> 231: // evacuation are not updated during evacuation. For both young and old regions r, it is essential that all
>> 232: // PLABs be made parsable at the end of evacuation. This is enabled by retiring all plabs at end of evacuation.
>> 233: region->concurrent_set_update_watermark(region->top());
>
> There's a race here. Multiple mutators may be updating watermark in parallel. It may be that the mutator who most recently allocated is not the mutator who makes the "most recent" overwrite of set_update_watermark().
>
> I think the better fix is to remove this code. Update refs should just assume that update watermark equals top for any region in the Old gen, and for any region that was in the Collector partition. It may not be easy to know which regions were "in the Collector partition". Maybe we use a Sentinel value for update_watermark on all such regions. Just overwrite update_watermark(nullptr)? And check for this in update-refs? Needs a solution, and solution needs to be documented in code comments.
I don't really know how watermark is used, but based on you comments and explanations I it might be possible to use top instead of watermark if is only used in the old gen, it won't be used in other young gen we could remove concurrent_set_update_watermark, I'll try to make the change and test it.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26171#discussion_r2683935723
More information about the shenandoah-dev
mailing list