Integrated: 8318986: Improve GenericWaitBarrier performance
Aleksey Shipilev
shade at openjdk.org
Wed Nov 22 17:58:23 UTC 2023
On Fri, 27 Oct 2023 15:40:11 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:
> See the symptoms, reproducer and analysis in the bug.
>
> Current code waits on `disarm()`, which effectively stalls leaving the safepoint if some threads lag behind. Having more runnable threads than CPUs nearly guarantees that we would wait for quite some time, but it also reproduces well if you have enough threads near the CPU count.
>
> This PR implements a more efficient `GenericWaitBarrier` to recover the performance. Most of the implementation discussion is in the code comments. The key observation that drives this work is that we want to reuse `Semaphore` and related counters without being stuck waiting for threads to leave. (AFAICS, futex-based `LinuxWaitBarrier` does roughly the same, but handles this reuse on futex side, by assigning the "address" per futex.)
>
> This issue affects everything except Linux. I initially found this on my M1 Mac, but pretty sure it is easy to reproduce on Windows as well. The safepoints from the reproducer in the bug improved dramatically on a Mac, see the graph below. The new version gives **orders of magnitude** better safepoint times. This also translates to much more active GC and attainable allocating rate, because GC throughput is not blocked by overly long safepoints.
>
> 
>
> Additional testing:
> - [x] MacOS AArch64 server fastdebug, `tier1`
> - [x] Linux x86_64 server fastdebug, `tier1 tier2 tier3` (generic wait barrier enabled explicitly)
> - [x] Linux AArch64 server fastdebug, `tier1 tier2 tier3` (generic wait barrier enabled explicitly)
> - [x] MacOS AArch64 server fastdebug, `tier2 tier3`
> - [x] Linux x86_64 server fastdebug, `tier4` (generic wait barrier enabled explicitly)
> - [x] Linux AArch64 server fastdebug, `tier4` (generic wait barrier enabled explicitly)
This pull request has now been integrated.
Changeset: 30462f9d
Author: Aleksey Shipilev <shade at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/30462f9da40d3a7ec18fcf46e2154fabb5fd4753
Stats: 286 lines in 2 files changed: 225 ins; 12 del; 49 mod
8318986: Improve GenericWaitBarrier performance
Reviewed-by: rehn, iwalulya, pchilanomate
-------------
PR: https://git.openjdk.org/jdk/pull/16404
More information about the hotspot-dev
mailing list