RFR: 8284161: Implementation of Virtual Threads (Preview) [v4]

Mandy Chung mchung at openjdk.java.net
Tue Apr 19 02:03:35 UTC 2022


On Sun, 17 Apr 2022 16:03:30 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> This is the implementation of JEP 425: Virtual Threads (Preview); TBD which JDK version to target.
>> 
>> We will refresh this PR periodically to pick up changes and fixes from the loom repo.
>> 
>> Most of the new mechanisms in the HotSpot VM are disabled by default and require running with `--enable-preview` to enable.
>> 
>> The patch has support for x64 and aarch64 on the usual operating systems (Linux, macOS, and Windows). There are stubs (calling Unimplemented) for zero and some of the other ports. Additional ports can be contributed via PRs against the fibers branch in the loom repo.
>> 
>> There are changes in many areas. To reduce notifications/mails, the labels have been trimmed down for now to hotspot, serviceability and core-libs. We'll add the complete set of labels when the PR is further along.
>> 
>> The changes include a refresh of java.util.concurrent and ForkJoinPool from Doug Lea's CVS. These changes will probably be proposed and integrated in advance of this PR.
>> 
>> The changes include some non-exposed and low-level infrastructure to support the (in draft) JEPs for Structured Concurrency and Scope Locals. This is to make life a bit easier and avoid having to separate VM changes and juggle branches at this time.
>
> Alan Bateman has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Refresh

src/java.base/share/classes/java/lang/System.java line 2173:

> 2171: 
> 2172:         // start Finalizer and Reference Handler threads
> 2173:         SharedSecrets.getJavaLangRefAccess().startThreads();

I think it would avoid any confusion if `VM.initLevel(1)` is the last step in `initPhase1`, i.e. call after this line.   Previously, the finalizer starts very early and it has to wait until initLevel is set to level 1 which guarantees that `JavaLangAccess` is available.  With this change, `JavaLangAccess` is already set.

src/java.base/share/classes/java/lang/ref/ReferenceQueue.java line 61:

> 59:     private final Condition notEmpty;
> 60: 
> 61:     void signal() { notEmpty.signalAll(); }

`signal()`, `await()` and `await(long)` methods are only used by `ReferenceQueue`.  Good to make them private.

src/jdk.management/share/classes/com/sun/management/HotSpotDiagnosticMXBean.java line 138:

> 136:      *
> 137:      * @param  outputFile the path to the file to create
> 138:      * @param  format the format to use (TEXT_PLAIN or JSON)

It's useful to link to `ThreadDumpFormat#TEXT_PLAN` and `ThreadDumpFormat#JSON`

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

PR: https://git.openjdk.java.net/jdk/pull/8166


More information about the serviceability-dev mailing list