RFR: 8319048: Monitor deflation unlink phase prolongs time to safepoint
David Holmes
dholmes at openjdk.org
Mon Oct 30 23:00:32 UTC 2023
On Mon, 30 Oct 2023 19:42:30 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
>
> @dcubed-ojdk, I think you'll be interested in this!
@shipilev the new settings may hit a sweet-spot for what you are measuring but we would need to run this through all our benchmarks too.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/16412#issuecomment-1786174130
More information about the hotspot-runtime-dev
mailing list