ForkJoinPool carrier starvation compensation for pinned virtual threads#52
Open
macarte wants to merge 1 commit intomacarte/PR3-winarm64from
Open
ForkJoinPool carrier starvation compensation for pinned virtual threads#52macarte wants to merge 1 commit intomacarte/PR3-winarm64from
macarte wants to merge 1 commit intomacarte/PR3-winarm64from
Conversation
When a pinned virtual thread's carrier blocks on a contended monitor,
the ForkJoinPool has no visibility that its worker is blocked. If all
carriers end up pinned on monitors, the VT holding the contested lock
can never get a carrier to run on, causing deadlock.
This adds FJP compensation that activates an idle worker or creates a
spare carrier when a pinned carrier is about to block on a monitor:
objectMonitor.cpp:
- compensate_pinned_carrier(): calls CarrierThread.beginMonitorBlock()
before the carrier blocks, saving/restoring pending monitor state to
handle nested monitor contention during worker thread creation
- end_compensate_pinned_carrier(): calls CarrierThread.endBlocking()
after the carrier acquires the monitor
- New includes: symbolTable.hpp, javaCalls.hpp
ForkJoinPool.java:
- tryCompensateForMonitor(): variant of tryCompensate that omits the
passive RC-only path (branch 2) and explicitly decrements RC so
signalWork sees the pool as under-active while carriers are blocked
- beginMonitorCompensatedBlock(): spin-loop wrapper returning the
RC_UNIT restoration value for endCompensatedBlock
- endCompensatedBlock: updated javadoc for monitor compensation path
JavaUtilConcurrentFJPAccess.java:
- Added beginMonitorCompensatedBlock to the shared secret interface
CarrierThread.java:
- beginMonitorBlock(): re-entrancy-guarded compensation that pins the
continuation during FJP compensation to prevent preemption
- ForkJoinPools.beginMonitorCompensatedBlock(): static bridge method
Author
|
manual rerun results |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a pinned virtual thread's carrier blocks on a contended monitor, the ForkJoinPool has no visibility that its worker is blocked. If all carriers end up pinned on monitors, the VT holding the contested lock can never get a carrier to run on, causing deadlock.
This adds FJP compensation that activates an idle worker or creates a spare carrier when a pinned carrier is about to block on a monitor:
objectMonitor.cpp:
ForkJoinPool.java:
JavaUtilConcurrentFJPAccess.java:
CarrierThread.java: