On Mon, 10 Jun 2024 07:36:50 GMT, Inigo Mediavilla Saiz <d...@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 <turban...@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

Reply via email to