RFR: 8293940: Some tests for virtual threads take too long

Daniel Fuchs dfuchs at openjdk.org
Fri Sep 30 10:03:21 UTC 2022


On Wed, 28 Sep 2022 08:07:25 GMT, Alan Bateman <alanb at openjdk.org> wrote:

> This is a test only change to split the execution of some of the larger tests for virtual threads and reduce the execution time of a few others.
> 
> The tests StructuredTaskScopeTest, ThreadFockTest and ThreadPerTaskExecutorTest contain a lot of tests and run with thread factories for both platform and virtual threads. These tests are changed to run twice, one with the thread factory for platform threads, the other for virtual threads. This allows the tests to run concurrently. A number of sleeps/delays in these tests are adjusted. StructuredTaskScopeTest goes from ~50s to two runs of ~15s. ThreadFockTest goes from 39s to two runs of 15s, ThreadPerTaskExecutorTest goes from 21s to two runs of 8.5. There is more that could be done but these tests are likely to change a bit the APIs evolve so it may not be worth doing now.
> 
> ThreadAPI also contains a lot of tests. A number of tests sleep to give time for a virtual thread to park or block. These sleeps are replaced with a poll of the thread state. A number of other tests are changed to use shorter sleeps. There are a few cleanups that include introducing a number of data providers and using a STPE for delayed actions. Its execution time goes from ~31s to ~12s.
> 
> CloseTest has two tests that sleep 1s and they are run with a data provider that produces six inputs so the sleep time adds up. These lengthy delays aren't needed for testing 
> 
> Finally, some of the stress changes have been changed. The two runs of PingPong are changed so they are in separate @test descriptions and the iteration count on a few tests has been reduced for release builds - the iteration count for debug builds is not changed.

I have gone through the proposed changes and they look reasonable.
I can't comment on the new threshold values which I assume have been obtained from careful experimentation.
If that makes the tests faster and if you checked that they remain stable in the CI then this looks like a good change!

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

Marked as reviewed by dfuchs (Reviewer).

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


More information about the core-libs-dev mailing list