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

Alan Bateman alanb at openjdk.org
Tue Jun 11 08:00:21 UTC 2024


On Mon, 10 Jun 2024 07:36:50 GMT, Inigo Mediavilla Saiz <duke at openjdk.org> wrote:

>> Print the stack traces of mounted virtual threads when calling `jcmd <pid> Thread.print`.
>
> Inigo Mediavilla Saiz has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains 15 additional commits since the last revision:
> 
>  - Merge remote-tracking branch 'upstream/master' into txominpelu_8330846_add_stack_vthreads
>  - Include virtual thread name in output
>  - Incorporate @tstuefe's remarks
>  - Remove dead code
>  - Remove extra indentation (leave it for the next PR)
>  - Cleanup test
>    
>    - Stop virtualthread
>    - Remove unneeded imports
>    - Remove modules that are not needed
>  - Fix copyright year
>  - Print mounted virtual thread after carrier
>  - Add indentation for virtual thread stack
>  - Update test/hotspot/jtreg/serviceability/dcmd/thread/PrintVirtualThreadTest.java
>    
>    Co-authored-by: Andrey Turbanov <turbanoff at gmail.com>
>  - ... and 5 more: https://git.openjdk.org/jdk/compare/0b955462...ba3385a4

test/hotspot/jtreg/serviceability/dcmd/thread/PrintVirtualThreadTest.java line 40:

> 38:  * @run testng PrintVirtualThreadTest
> 39:  */
> 40: public class PrintVirtualThreadTest {

It might be helpful to put  "Mounted" into the test name as this is a test to check that a mounted virtual thread appears in the Thread.print output, something like PrintMountedVirtualThread.

test/hotspot/jtreg/serviceability/dcmd/thread/PrintVirtualThreadTest.java line 52:

> 50:         output.shouldMatch(".*at " + Pattern.quote(DummyRunnable.class.getName()) + "\\.run.*");
> 51:         output.shouldMatch(".*at " + Pattern.quote(DummyRunnable.class.getName()) + "\\.compute.*");
> 52:         shouldFinish.set(true);

This just checks that the stack frames are printed. I think you also want to check that the output contains and line with "Mounted virtual thread and the thread ID.

test/hotspot/jtreg/serviceability/dcmd/thread/PrintVirtualThreadTest.java line 78:

> 76:             while (true) {
> 77:                 if (shouldFinish.get()) {
> 78:                     break;

You can use Thread.onSpinWait in the loop to reduce the impact of the tight loop.

Also you can use `while (!shouldFinish.get())` to avoid the explicit break.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/19482#discussion_r1634372088
PR Review Comment: https://git.openjdk.org/jdk/pull/19482#discussion_r1634377680
PR Review Comment: https://git.openjdk.org/jdk/pull/19482#discussion_r1634374957


More information about the hotspot-runtime-dev mailing list