RFR: 8330846: Add stacks of mounted virtual threads to the HotSpot thread dump

Alan Bateman alanb at openjdk.org
Thu May 30 16:42:01 UTC 2024


On Thu, 30 May 2024 14:13:34 GMT, Inigo Mediavilla Saiz <duke at openjdk.org> wrote:

> Print the stack traces of mounted virtual threads when calling `jcmd <pid> Thread.print`.

Thanks for take this one. Here's the result with the changes in 1a75277e.

"ForkJoinPool-1-worker-1" #25 [33795] daemon prio=5 os_prio=31 cpu=46574.42ms elapsed=47.15s tid=0x00007f81670d1a00  [0x000070000e9a4000]
   Carrying virtual thread #24
	at jdk.internal.vm.Continuation.run(java.base/Continuation.java:262)
	at java.lang.VirtualThread.runContinuation(java.base/VirtualThread.java:283)
	at java.lang.VirtualThread$$Lambda/0x00000001220b2868.run(java.base/Unknown Source)
	at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.compute(java.base/ForkJoinTask.java:1726)
	at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.compute(java.base/ForkJoinTask.java:1717)
	at java.util.concurrent.ForkJoinTask$InterruptibleTask.exec(java.base/ForkJoinTask.java:1641)
	at java.util.concurrent.ForkJoinTask.doExec(java.base/ForkJoinTask.java:507)
	at java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(java.base/ForkJoinPool.java:1455)
	at java.util.concurrent.ForkJoinPool.runWorker(java.base/ForkJoinPool.java:2031)
	at java.util.concurrent.ForkJoinWorkerThread.run(java.base/ForkJoinWorkerThread.java:189)
   Carrying virtual thread #24
	at Main.lambda$main$0(Main.java:7)
	at java.lang.VirtualThread.run(java.base/VirtualThread.java:381)


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
- indent the stack trace of the mounted virtual thread
- list the mounted virtual threads at the end

-------------

PR Comment: https://git.openjdk.org/jdk/pull/19482#issuecomment-2140202464


More information about the serviceability-dev mailing list