RFR: 8319048: Monitor deflation unlink phase prolongs time to safepoint
Daniel D. Daugherty
dcubed at openjdk.org
Mon Oct 30 20:59:33 UTC 2023
On Mon, 30 Oct 2023 08:20:37 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:
> See the symptoms, reproducer, and analysis in the bug.
>
> This PR fixes the issue by providing a smaller batch size for unlinking. The unlinking batch size basically defines two things: a) how often do we check for safepoint (`ObjectSynchronizer::chk_for_block_req` in the method below); and b) how much overhead we have on mutating the monitor lists. If we unlink monitors one by one, then in a worst case, we would do a CAS on `head` for every monitor, which is bound to be expensive.
>
> There is a major problem in current code: we only check for safepoint every 1M monitors, which might take a while. Even if we spend 1ns per monitor, that's already +1ms in TTSP. There is a secondary problem that comes with searching for new `prev` if monitor insertion happened while we were preparing the batch for unlinking.
>
> The experiments with the reproducer from the bug shows that the threshold of 500 works well: it mitigates TTSP latencies nearly completely, while still providing the large enough batch size to absorb list mutation overheads. See how bad outliers are in baseline, and how outliers get lower with lower batch, and almost completely disappear at 500. I believe the difference between baseline and `MUB=1M` is short-cut-ting the search for new `prev`.
>
> 
>
> Additional testing:
> - [x] Linux AArch64 server fastdebug, `tier1 tier2 tier3`
> - [x] Ad-hoc performance tests, see above
I'm definitely interested, but I'm only in the office for two days this week.
I can't promise that I'll get to this review before Tuesday evening.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/16412#issuecomment-1786027559
More information about the hotspot-runtime-dev
mailing list