[master] RFR: OMWorld: Spin Changes [v3]

Coleen Phillimore coleenp at openjdk.org
Tue May 28 14:21:16 UTC 2024


On Tue, 28 May 2024 08:14:35 GMT, Axel Boldt-Christmas <aboldtch at openjdk.org> wrote:

>> The fast lock spinning uses `sched_yield` which tends to be discouraged for spin locking code. Instead only use `SpinPause` with exponential backoff. Where after each failed CAS wait for exponentially more time until trying again in an attempt to reduce cache contention. 
>> 
>> This change also makes the spinning aware of safepoints, and tries to fast track the execution to next poll, which is either when successfully locked (VM backedge transition) or when going into blocked to enter the ObjectMonitor.
>> 
>> Have not removed `OMSpins` yet, as the exact value is not determined yet. It may have to be platform specific as `SpinPause` have different characteristics on different hardware. OMSpins is the number of fast lock, with each attempt spinning for twice as much as the last, so the total number of spins are on the order of O(2^OMSpins). It will probably land somewhere on the range of 7-14 (128 -16384 spins)
>
> Axel Boldt-Christmas has updated the pull request incrementally with two additional commits since the last revision:
> 
>  - Improve spinning and add comment
>  - Add OMSpins description

A couple more comments or comment requests, increasingly minor.

src/hotspot/share/runtime/lightweightSynchronizer.cpp line 573:

> 571: 
> 572:   markWord mark = obj->mark();
> 573:   const auto try_spin = [&]() {

Instead of try_spin, can you name this should_spin since it doesn't actually spin.

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

Marked as reviewed by coleenp (Committer).

PR Review: https://git.openjdk.org/lilliput/pull/177#pullrequestreview-2082934516
PR Review Comment: https://git.openjdk.org/lilliput/pull/177#discussion_r1617326225


More information about the lilliput-dev mailing list