On Mon, 2 Sep 2024 12:25:05 GMT, Alan Bateman <[email protected]> wrote:
> This PR proposes to add a JDK-specific monitoring and management interface
> for the virtual thread scheduler. The interface is named
> VirtualThreadSchedulerMXBean and allows JMX based tooling monitor/manage the
> scheduler's target parallelism and monitor thread counts.
>
> The JDK 5/6 era JDK-specific management interfaces are in
> jdk.management/com.sun.management. The proposal here is to start afresh in
> the jdk.management package, thus establishing a "new home" for JDK-specific
> management interfaces going forward.
>
> jdk.test.lib.thread.VThreadRunner is test infrastructure used by several
> tests to set or ensure some level of parallelism. This is changed from using
> deep reflection to using the MXBean to access the target parallelism, which
> requires changes to the `@modules` tag tests in a number of tests (some tests
> no longer need to open java.base/java.lang).
>
> (The changes proposed here have been in the loom repo for some time. A
> related command for the jcmd tool is also in that repo and will be proposed
> separately).
Typo (`imp` → `impl`):
The `BaseVirtualThreadSchedulerImpl` hierarchy can be `sealed`:
src/jdk.management/share/classes/com/sun/management/internal/VirtualThreadSchedulerImpls.java
line 56:
> 54: * Base implementation of VirtualThreadSchedulerMXBean.
> 55: */
> 56: private abstract static class BaseVirtualThreadSchedulerImpl
Suggestion:
private abstract static sealed class BaseVirtualThreadSchedulerImpl
src/jdk.management/share/classes/com/sun/management/internal/VirtualThreadSchedulerImpls.java
line 59:
> 57: implements VirtualThreadSchedulerMXBean {
> 58:
> 59: abstract void impSetParallelism(int size);
Suggestion:
abstract void implSetParallelism(int size);
src/jdk.management/share/classes/com/sun/management/internal/VirtualThreadSchedulerImpls.java
line 64:
> 62: public final void setParallelism(int size) {
> 63: Util.checkControlAccess();
> 64: impSetParallelism(size);
Suggestion:
implSetParallelism(size);
src/jdk.management/share/classes/com/sun/management/internal/VirtualThreadSchedulerImpls.java
line 97:
> 95: * implemented with continuations + scheduler.
> 96: */
> 97: private static class VirtualThreadSchedulerImpl extends
> BaseVirtualThreadSchedulerImpl {
Suggestion:
private static final class VirtualThreadSchedulerImpl extends
BaseVirtualThreadSchedulerImpl {
src/jdk.management/share/classes/com/sun/management/internal/VirtualThreadSchedulerImpls.java
line 119:
> 117:
> 118: @Override
> 119: void impSetParallelism(int size) {
Suggestion:
void implSetParallelism(int size) {
src/jdk.management/share/classes/com/sun/management/internal/VirtualThreadSchedulerImpls.java
line 159:
> 157: * by platform threads.
> 158: */
> 159: private static class BoundVirtualThreadSchedulerImpl extends
> BaseVirtualThreadSchedulerImpl {
Suggestion:
private static final class BoundVirtualThreadSchedulerImpl extends
BaseVirtualThreadSchedulerImpl {
src/jdk.management/share/classes/com/sun/management/internal/VirtualThreadSchedulerImpls.java
line 167:
> 165:
> 166: @Override
> 167: void impSetParallelism(int size) {
Suggestion:
void implSetParallelism(int size) {
-------------
PR Review: https://git.openjdk.org/jdk/pull/20816#pullrequestreview-2276238096
PR Review: https://git.openjdk.org/jdk/pull/20816#pullrequestreview-2276600238
PR Review Comment: https://git.openjdk.org/jdk/pull/20816#discussion_r1741551781
PR Review Comment: https://git.openjdk.org/jdk/pull/20816#discussion_r1741310375
PR Review Comment: https://git.openjdk.org/jdk/pull/20816#discussion_r1741310424
PR Review Comment: https://git.openjdk.org/jdk/pull/20816#discussion_r1741552166
PR Review Comment: https://git.openjdk.org/jdk/pull/20816#discussion_r1741310517
PR Review Comment: https://git.openjdk.org/jdk/pull/20816#discussion_r1741552822
PR Review Comment: https://git.openjdk.org/jdk/pull/20816#discussion_r1741310573