8330846: (jstack) Add stacks of mounted virtual threads

Alan Bateman Alan.Bateman at oracle.com
Wed Jun 5 04:52:29 UTC 2024


On 04/06/2024 21:52, Iñigo Mediavilla wrote:
> Hello,
>
> While there's ongoing work on:
>
> https://github.com/openjdk/jdk/pull/19482
>
> to add the stack trace of mounted virtual threads to the `jcmd <pid> 
> Thread.print` command, I'm starting to think about how I could do to 
> print the stack trace for virtual threads from `jstack` but I'm not 
> sure about what would be the best approach, so I'd be happy to get 
> people's thoughts on the topic.

JDK-8330846 is about showing the stack traces of mounted virtual 
threads, I don't think pull/19482 should be expanded to do anything 
else. For the PR then I think you are just waiting for Thomas Stuefe's 
change with support for automatic indentation and of course converging 
on some details of the output.

If you are asking if it should include the stack traces of unmounted 
virtual threads then we decided some time ago to not do that. The 
Thread.print commands runs as a VM operation so the at a safepoint. 
Adding more work to that, to walk the heap to find virtual thread 
objects, would just increase the STW time. The other issue is that the 
output (text format) doesn't scale to hundreds of thousands of threads. 
You might ask about de-duplication but that is just adding more overhead 
to the thread dump and may be better left to tools that process the 
thread dump. These are issues/reasons for Thread.dump_to_file. It uses 
the tree of thread groupings to find all threads.

-Alan


More information about the loom-dev mailing list