RFR: Use timed wait to sleep control thread [v2]

Aleksey Shipilev shade at openjdk.java.net
Thu Apr 8 06:30:05 UTC 2021


On Wed, 7 Apr 2021 20:31:09 GMT, earthling-amzn <github.com+71722661+earthling-amzn at openjdk.org> wrote:

>> Using a timed `wait` rather than a naked sleep allows the control thread to be more responsive to requests from mutators and the regulator thread to start GC cycles. The sleep time is also changed from `ShenandoahControlIntervalMin` to `ShenandoahControlIntervalMax` to reduce unnecessary polling cycles. We could use a plain `wait`, but the control thread is responsible for periodically sending allocation metrics to the `pacer`.
>
> earthling-amzn has updated the pull request incrementally with two additional commits since the last revision:
> 
>  - Increase mutex rank of gc waiters
>    
>    This lets us take the control thread's lock to notify it without tripping the deadlock detector.
>  - Remove unnecessary enum namespace

OK then, with one minor stylistic nit.

src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp line 54:

> 52:   ConcurrentGCThread(),
> 53:   _alloc_failure_waiters_lock(Mutex::leaf, "ShenandoahAllocFailureGC_lock", true, Monitor::_safepoint_check_always),
> 54:   _gc_waiters_lock(Mutex::safepoint, "ShenandoahRequestedGC_lock", true, Monitor::_safepoint_check_always),

Look at `src/hotspot/share/runtime/mutexLocker.cpp`: if we need to elevate the lock above/below the `leaf`, the usual thing to do is to say `leaf + 1` or `leaf - 1`. I would prefer to make `_control_lock` into `leaf - 1`, as that one is special, not all other locks.

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

Marked as reviewed by shade (Reviewer).

PR: https://git.openjdk.java.net/shenandoah/pull/28


More information about the shenandoah-dev mailing list