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
8249004: Reduce ThreadsListHandle overhead in relation to direct handshakes #4677
Closed
+115
−69
Closed
Changes from 13 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
8162b22
8249004: Reduce ThreadListHandle overhead in relation to direct hands…
dcubed-ojdk bc82cfa
Merge branch 'master' into JDK-8249004
dcubed-ojdk 11f5976
Merge branch 'master' into JDK-8249004
dcubed-ojdk 507bcbc
Merge branch 'master' into JDK-8249004
dcubed-ojdk 093ad30
Merge branch 'master' into JDK-8249004
dcubed-ojdk a214b28
Merge branch 'master' into JDK-8249004
dcubed-ojdk 4e207e1
8249004.cr1.patch
dcubed-ojdk 4841686
dholmes CR - change NULL to nullptr.
dcubed-ojdk 9518a9a
coleenp CR - add comments to clarify what WB_HandshakeReadMonitors() …
dcubed-ojdk 045b3e0
Merge branch 'master' into JDK-8249004
dcubed-ojdk 3e1d1b0
8249004.cr2.patch
dcubed-ojdk 86fcdfb
8249004.cr3.patch
dcubed-ojdk 9117350
8249004.cr4.patch
dcubed-ojdk fe28cbe
coleenp CR - clarify need for ThreadsListHandle in JvmtiEventControll…
dcubed-ojdk File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
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.
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.
Good catch on the missing TLH for this code.
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.
It wasn't quite missing from the baseline code. This version of execute():
Handshake::execute(HandshakeClosure* hs_cl, JavaThread* target)
used to always create a ThreadsListHandle. I added a
ThreadsListHandle*
parameter to that version and created a wrapper with the existing signature
to pass
nullptr
to the execute() version with theThreadsListHandle*
parameter. What that means is that all existing callers of:
Handshake::execute(HandshakeClosure* hs_cl, JavaThread* target)
no longer had a ThreadsListHandle created for them. With the new sanity
check in place, I shook the trees to make sure that we had explicit
ThreadsListHandles in place for the locations that needed them.
JvmtiEventControllerPrivate::recompute_enabled()
happened to beone of the places where the ThreadsListHandle created by execute()
was hiding the fact that
recompute_enabled()
needed one.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.
Should the ThreadsListHandle protect JvmtiThreadState::first also? If state->next() needs it why doesn't the first entry need this? There's no atomic load on the _head field.
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
ThreadsListHandle
protectsJavaThread
objects notJvmtiThreadState
objects.JvmtiThreadState::first()
returns the head of the global list ofJvmtiThreadState
objects for the system. Each
JvmtiThreadState
object contains aJavaThread*
andwe have to protect use of the
JavaThread*
which can happen in therecompute_thread_enabled(state)
call below.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.
JvmtiThreadState objects point to JavaThread and vice versa, so I still don't see why you don't protect the first element.
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.
I've written up a rather long analysis about how the use of
JvmtiThreadState_lock
in
JvmtiEventControllerPrivate::recompute_enabled()
means that we can safelytraverse the JvmtiThreadState list returned by
JvmtiThreadState::first()
withoutracing with an exiting JavaThread. I've sent it to you via direct email.
I could amend the comment above the ThreadsListHandle like this:
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.
Yes, this comment is good and it does explain why it's safe and why the TLH is there. Thanks for doing the deep dive and explanation.
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 comment has been pushed to this PR.