RFR: 8308507: G1: GClocker induced GCs can starve threads requiring memory leading to OOME
Ivan Walulya
iwalulya at openjdk.org
Mon May 22 11:51:17 UTC 2023
Please review this change which fixes the thread starvation problem during allocation for G1.
The starvation problem is not limited to GCLocker, however, currently, it manifests as an OOME only when GCLocker is active. In other cases, the starvation only affects the "starved" thread as it may loop indefinitely.
Starvation with an active GCLocker happens as below:
1. Thread A tries to allocate memory as normal, and tries to start a GC; the GCLocker is active and so the thread gets stalled waiting for the GC.
2. GCLocker induced GC executes and frees some memory.
3. Thread A does not get any of that memory, but other threads also waiting for memory.
4. Goto 1 until the gclocker retry count has been reached.
In this change, we take the general approach to solving starvation problems with announcement tables (request queues). On slow allocation, a thread that wishes to complete an Allocation GC and then attempt an allocation announces its allocation request before proceeding to participate in a race to execute a GC safepoint. Whichever thread succeeds in executing the Allocation GC safepoint will be tasked with completing all allocation requests that were announced before the safepoint. This guarantees that all announced allocation requests are either satisfied during the safepoint, or failed in case there is not enough memory to complete all requests. This effectively deals with the starvation issue and reduces the number of allocation GCs triggered.
Note: The change also adopts ZList from ZGC and makes it available under utilities as DoublyLinkedList with slight modifications.
Testing: Tier 1-7
-------------
Commit messages:
- remove debug info
- ready for review
Changes: https://git.openjdk.org/jdk/pull/14077/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=14077&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8308507
Stats: 908 lines in 12 files changed: 700 ins; 149 del; 59 mod
Patch: https://git.openjdk.org/jdk/pull/14077.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/14077/head:pull/14077
PR: https://git.openjdk.org/jdk/pull/14077
More information about the hotspot-dev
mailing list