RFR: 8291429: java/lang/Thread/virtual/ThreadAPI.java timed out on single core system

Chris Plummer cjplummer at openjdk.org
Wed Oct 5 19:09:27 UTC 2022


On Tue, 4 Oct 2022 17:59:36 GMT, Alan Bateman <alanb at openjdk.org> wrote:

> This is a test only change for two tests for virtual threads that hang/timeout on single core systems. The two tests involve pinning and require at least two carrier threads. The test lib used by these tests is updated to define a new method that ensures parallelism is at least a given value and both tests are updated to use this. There are a number of tests in the debugger area that may potentially use this in the future.

test/jdk/java/lang/management/ThreadMXBean/VirtualThreadDeadlocks.java line 30:

> 28:  *   platform and virtual threads in deadlock
> 29:  * @enablePreview
> 30:  * @modules java.base/java.lang:+open java.management

Can you explain the need for this change?

test/jdk/java/lang/management/ThreadMXBean/VirtualThreadDeadlocks.java line 68:

> 66:     public static void main(String[] args) throws Exception {
> 67:         // need at least two carrier threads due to pinning
> 68:         VThreadRunner.ensureParallelism(2);

In this test case why is there no need to maintain a reference to the returned AutoCloseable? Isn't there a chance it can be collected and the old parallelism value restored while the test is running.

test/lib/jdk/test/lib/thread/VThreadRunner.java line 32:

> 30: 
> 31: /**
> 32:  * Helper class for running tests tasks in a virtual thread.

"tests" => "test"

test/lib/jdk/test/lib/thread/VThreadRunner.java line 149:

> 147:      * Ensures that the virtual thread scheduler's target parallelism is at least the
> 148:      * given size. If the current parallelism is less than size then it is changed to
> 149:      * size. This method returns an AutoCloseable, its close method restores the

"     * size. This method returns an AutoCloseable whose close method..."

test/lib/jdk/test/lib/thread/VThreadRunner.java line 176:

> 174:                     if (!closed) {
> 175:                         closed = true;
> 176:                         pool.setParallelism(parallelism);

What is the rationale for restoring the parallelism? It's just a test. Is this really necessary? Are we reusing the JVM to run other tests, and even if we are does it matter?

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

PR: https://git.openjdk.org/jdk/pull/10562


More information about the core-libs-dev mailing list