RFR: 8336254: Virtual thread implementation + test updates

Serguei Spitsyn sspitsyn at openjdk.org
Thu Jul 18 10:55:32 UTC 2024


On Thu, 11 Jul 2024 17:30:21 GMT, Alan Bateman <alanb at openjdk.org> wrote:

> Bringover some of the changes accumulated in the loom repo to the main line, most of these changes are test updates and have been baking in the loom repo for several months. The motive is partly to reduce the large set of changes that have accumulated in the loom repo, and partly to improve robustness and test coverage in the main line. The changes don't include any of the larger changes in the loom repo that are part of future JEPs.
> 
> Implementation:
> - Robustness improvements to not throw OOME when unparking a virtual thread.
> - Robustness improvements to reduce class loading when a virtual thread parks or parks when pinned (jdk.internal.misc.VirtualThreads is removed, jdk.internal.event.VirtualThreadPinnedEvent is eagerly loaded)
> - VirtualThread changes to reduce contention on timer queues when doing timed-park
> 
> Tests:
> - New tests for monitor enter/exit/wait/notify (this is a subset of the tests in the loom repo, we can't move many tests because they depend on on the changes to the object monitor implementation)
> - New test infrastructure to allow tests use a custom scheduler. This updates many tests to make use of this infrastructure, the "local" ThreadBuidlers is removed.
> - More test scenarios added to ThreadAPI and JVMTI GetThreadStateTest.java 
> - New test for ThreadMXBean.getLockedMonitor with synchronized native methods
> - Reimplement of JVMTI VThreadEvent test to improve reliability
> - Rename some tests to get consistent naming
> - Diagnostic output in several stress tests to help trace progress in the event of a timeout
> 
> Testing: tier1-6

Q: There are some new files with a copyright year ranges. They are probably renamed files. Should their copyright years be updated?

test/jdk/java/lang/Thread/virtual/ThreadAPI.java line 1113:

> 1111:     @Test
> 1112:     void testYield3() throws Exception {
> 1113:         assumeTrue(VThreadScheduler.supportsCustomScheduler(), "No support for custom schedulers");

Q: What was the reason to rename `testYield2()` to `testYield3()`?

test/jdk/java/lang/Thread/virtual/stress/Skynet.java line 72:

> 70:         System.out.format("Result: %d in %s ms%n", sum, (end-start));
> 71:         if (sum != expected)
> 72:             throw new RuntimeException("Expected " + expected);

Nit: This probably needs a copyright update.

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

PR Review: https://git.openjdk.org/jdk/pull/20143#pullrequestreview-2185389469
PR Review Comment: https://git.openjdk.org/jdk/pull/20143#discussion_r1682627996
PR Review Comment: https://git.openjdk.org/jdk/pull/20143#discussion_r1682604568


More information about the serviceability-dev mailing list