-
Notifications
You must be signed in to change notification settings - Fork 721
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Loom Support: Pin Counters #15383
Loom Support: Pin Counters #15383
Conversation
runtime/oti/j9nonbuilder.h
Outdated
@@ -4885,6 +4885,7 @@ typedef struct J9VMContinuation { | |||
UDATA* stackOverflowMark; | |||
UDATA* stackOverflowMark2; | |||
J9JavaStack* stackObject; | |||
UDATA pinCount; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this separate from the others?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or perhaps, I'm misinterpreting this. Is that to track to number of times the continuation has been pinned?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it is a property of the continuation. Others are properties of the thread.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or perhaps, I'm misinterpreting this. Is that to track to number of times the continuation has been pinned?
Yes.
I don't see linkNext
and linkPrevious
fields in J9VMContinuation
. Will J9VMThread
maintain a list of Continuations
? To support Continuation.isPinned
, it needs to be a list since the parent of a Continuation
also needs to be checked to determine if it is pinned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tracking continuation lineage can be done in java code (ie. continuation.parent/child).
I don't see linkNext and linkPrevious fields in J9VMContinuation
This was intended for the purposes of finding all continuations in core dumps
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, it looks like the pinning fields are a lot like the interpreterfields in that the "live" versions are on the vmthread, and the "saved" versions are on the j9vmcontinuation.
So the short answer is all three can be put on the thread (this way it remains a fast path access). When we add support for nesting we'll need to add all three to the continuation as well. Updating the fields in the continuation will be handled by the code that does the enter/yield.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pin/unpin natives pin the current continuation (and in the case of nesting, the most deeply nested one), which will always be the one with the live state on the j9vmthread.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated as suggested. Note: RI handles nested continuations in its current implementation. Our current implementation won't be able to handle the below example. We are forcing a 1-to-1 relationship between a ContinuationScope
and Continuation
.
public static boolean isPinned(ContinuationScope scope) {
ContinuationScope X { Continuation A, Continuation B, Continuation C }
Continuation A { //Pinned
...
Continuation B { //Pinned
...
Continuation C {
...
}
...
}
...
}
If nesting is required then we would need to put all 3 counters in the continuation object
We may only need ownedMonitorCount
and pinCount
in continuation. But, we will need to keep ownedMonitorCount
in J9VMThread
. We will also need to stackwalk in Coninuation.isPinned(ContinuationScope scope)
to determine if any of the nested continuations has a stack frame on the thread. This will remove the need for callOutCount
in J9VMThread
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since RI currently handles nested continuations, should we do the same?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will, but for the purposes of unblocking JIT work I think we can keep this PR to the minimal set of changes we need right now
c74eba5
to
7bc8de4
Compare
Jenkins test sanity amac jdk19 |
|
Is there a good reason to add the flag in this PR? It's not something the JIT will need to see. I'd prefer if it were added and used in the same PR. |
As per #15175 (comment), the JIT plans to directly check if the bit is set. |
cb66784
to
df0d5c2
Compare
Fixed. Testing locally. |
Jenkins test sanity amac jdk19 |
I don't see why the JIT would check a bit (runtime checks are the very last thing the JIT ever wants to do). I'm also not clear on what thread this bit would be set - there are no J9VMThreads for virtual threads last time we discussed this. |
I suppose it's the carrier thread that gets the bit. To me, it would make more sense to inc/dec the counter in the inline JIT monent/exit code always (if the JCL level is high enough), and zero the counters whenever a vthread is mounted (we don't care about the values on the carrier thread itself). |
The JIT needs a fast way to tell if there is a virtual thread mounted on the carrier thread (j9vmthread) so they know if they need to update the pin state counters or not. The flag seems like the simplest way. They could also check |
@0xdaryl what are your thoughts on this? |
The test failure occurs in
I am investigating. Meanwhile, a decision on the new approach can be finalized. |
We have our meeting today, so we can discuss. |
The suggestion for a flag check was based on the understanding that the counters could only be updated under certain conditions and as a much faster alternative to calling out to the VM to determine those conditions (whether a virtual thread is mounted). If that's not true then I think unconditionally inc/dec'ing a counter will be a good solution (assuming the counter fields are on the VMThread and are in the cache). |
Reasons for pinning: public enum Pinned { /** In native code */ NATIVE, /** Holding monitor(s) */ MONITOR, /** In critical section */ CRITICAL_SECTION } Support for eclipse-openj9#15174 and eclipse-openj9#15175: - J9VMThread->continuationPinCount will support native methods in class Continuation: pin() and unpin(). It will also be associated to Pinned.CRITICAL_SECTION. - J9VMThread->ownedMonitorCount will be associated to Pinned.MONITOR. - J9VMThread->callOutCount will be associated to Pinned.NATIVE. Signed-off-by: Babneet Singh <sbabneet@ca.ibm.com>
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Zeroing the fields is unnecessary but we can fix that later.
Reasons for pinning:
Support for #15174 and #15175:
J9VMThread->continuationPinCount
will support native methods inclass Continuation
:pin()
andunpin()
. It will also be associated toPinned.CRITICAL_SECTION
.J9VMThread->ownedMonitorCount
will be associated toPinned.MONITOR
.J9VMThread->callOutCount
will be associated toPinned.NATIVE
.Signed-off-by: Babneet Singh sbabneet@ca.ibm.com