-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8330846: Add stacks of mounted virtual threads to the HotSpot thread dump #19482
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
8330846: Add stacks of mounted virtual threads to the HotSpot thread dump #19482
Conversation
|
👋 Welcome back txominpelu! A progress list of the required criteria for merging this PR into |
|
@txominpelu This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be: You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 41 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@dholmes-ora, @AlanBateman) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
|
@txominpelu The following labels will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command. |
Webrevs
|
|
Thanks for take this one. Here's the result with the changes in 1a75277. Note that the line "Carrying virtual thread #24" is printed twice. Also it's not immediately clear that there are two stack traces. You'll likely get different opinions on how mounted virtual threads should be presented. A few things to try
|
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.
Do you look at JavaThread::print_vthread_stack_on? The last thing we need is yet-another-version of stack printing code.
|
I'd probably give preference to the stack of the virtual thread, as the stack of the carrier when a vthread is mounted is generally quite uninteresting: |
|
Thanks for your comments @AlanBateman and @dholmes-ora !
|
You will different get different opinions on how it is presented. Can you also try putting a new section that lists the mounted virtual threads and their stack trace. If the virtual thread has a name then it can be shown too. |
|
In ae690b2 I've :
This is the way that the output looks like with the new changes: |
|
I also find the duplication of the stack printing code unfortunate. It would be nice to reuse |
That suggests to me that we have to iterate the list of all threads twice ?? If so that seems not ideal. |
Just what I was about to query :) I'm not sure what the const issue is. Printing a stack certainly should not modify anything. |
test/hotspot/jtreg/serviceability/dcmd/thread/PrintVirtualThreadTest.java
Outdated
Show resolved
Hide resolved
…adTest.java Co-authored-by: Andrey Turbanov <turbanoff@gmail.com>
|
Sorry, I don't know what I did wrong last week, but when I tried to rely on In any case, it seems to be working now with 59b18db. Thanks for insisting, and sorry for the confusion.
|
I think that both approaches suggested by @AlanBateman would work, but I personally like the fact that having the virtual thread being displayed on top of the carrier thread allows seeing the full stack trace together. I've tried to preserve that approach while calling |
|
About the output format:
|
|
I don't think showing the frames of the mounted virtual thread before the carrier thread frames is the best way to show this. For one thing, it appears immediately after the carrier's thread name/details and state. So I think Ron's suggestion to clearly label it as the mounted virtual thread after the carrier stack trace would be good to try. |
|
Thanks @AlanBateman and @pron ! Based on your comments I've added 9acbf29. That provides the following output: |
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.
Sorry for the delay. Leaving the indentation to another PR is fine. Thanks.
| output.shouldMatch(".*at " + Pattern.quote(DummyRunnable.class.getName()) + "\\.run.*"); | ||
| output.shouldMatch(".*at " + Pattern.quote(DummyRunnable.class.getName()) + "\\.compute.*"); | ||
| output.shouldMatch("Mounted virtual thread " + "\"Dummy Vthread\"" + " #" + vthread.threadId()); | ||
| shouldFinish.set(true); |
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.
One other suggestion is to use a try-finally block here. Put L48-53 in the block and set shouldFinish in the finally block. That way if the test fails then it won't leave a spinning thread to disrupt the next test that runs in the agent VM.
Also just to say that we've mostly used JUnit for new tests in recent releases, moving away from TestNG for new tests.
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.
Thanks @AlanBateman ! In commits 05d861c and 4d6a8cc I've incorporated your suggestions.
| * @summary Test of diagnostic command Thread.print with virtual threads | ||
| * @requires vm.continuations | ||
| * @library /test/lib | ||
| * @modules java.base |
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 @modules line isn't needed, it's not possible to have a run-time image without java.base.
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.
Thanks for taking feedback, I don't have any other comments.
Thanks a lot for all your comments ! 🙇 |
|
/integrate |
|
@txominpelu |
|
/sponsor |
|
Going to push as commit fcedde8.
Your commit was automatically rebased without conflicts. |
|
@dholmes-ora @txominpelu Pushed as commit fcedde8. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
|
I should have asked before sponsoring this but what testing was done with this? Do all our serviceability tests pass with this change? (I guess I will find out later today in our CI.) |
|
I've created JDK-8334215 with issues found when trying to sync up the loom repo. The tests in that repo are typically run with JTREG_TEST_THREAD_FACTORY=Virtual and can tickle issue that we don't always see immediately in main line. |
|
Thanks for the follow up @AlanBateman. I can take care of creating the PR with the proposed fix. I'm still struggling to understand this sentence though: Would you mind explaining why unparking the main (virtual) thread can end up with the main thread observing the dummy thread in transition ? |
The unpark of main requires queueing the task for main. This can trigger a new FJP worker to be started and there are several points where it may park. For reason that are complicated to go into here, this happens in the context of the carrier. The thread dump at this point is seeing a mounted continuation but JavaThread._vthread is pointing to self temporarily. |
|
In that case the one that would transition would be the "dummy vthread" or the "main virtual thread" ? Based on the explanation it sounds like the main virtual thread is the one having to be scheduled and that may go through transitions but in the JBS description I understood that the one that could be subject to transitions after the countdown call was the dummy vthread. |
|
It's the countDown by "dummy" thread will unpark "main". The queuing and starting of the second FJ worker thread is happening in the context of dummy's carrier (not dummy itself). We want to eventually remove these temporary transitions, at least for the default scheduler, but aren't there yet. I've attached an initial patch to JDK-8334215 for the issues. |
|
Thanks a lot @AlanBateman ! That helps me to get a better understanding of what's going on. I've created a PR with the patch that you shared in JDK-8334215 |
Print the stack traces of mounted virtual threads when calling
jcmd <pid> Thread.print.Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/19482/head:pull/19482$ git checkout pull/19482Update a local copy of the PR:
$ git checkout pull/19482$ git pull https://git.openjdk.org/jdk.git pull/19482/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 19482View PR using the GUI difftool:
$ git pr show -t 19482Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/19482.diff
Webrev
Link to Webrev Comment