RFR: 8303242: ThreadMXBean issues with virtual threads [v2]

Alan Bateman alanb at openjdk.org
Wed Mar 1 10:00:50 UTC 2023


> This PR covers a number of issues with j.l.management.ThreadMXBean, and the JDK-specific extension c.s.management.ThreadMXBean, when there are virtual threads in use.
> 
> As background, ThreadMXBean was re-specified in Java 19 to support the monitoring and management of platform threads. It does not support virtual threads as their potential number, and the need to find a thread by id, does not make sense for this API. At the same time, JDK 19 introduced an alternative implementation of virtual threads for Zero and ports without continuations support in the VM. This alternative implementation of virtual threads means a JavaThread per virtual thread and so requires filtering to ensure that the API behaves as specified. For the initial implementation, the filtering was done in the ThreadMXBean implementation. That works for most functions but not for getThreadXXXTime(long[]) and getThreadAllocatedBytes(long[]) where the filtering needs to be pushed down to the management code.
> 
> The changes in this PR move the filtering to the management functions (jmm_XXX) so they only return information about platform threads. There are some minor adjustments to the API docs (see linked CSR). Test coverage is expanded as we didn't include tests for c.s.management.ThreadMXBean with virtual threads in JDK 19.
> 
> Testing tier1-3 (jdk_management test group is in test/jdk/:tier3), plus sanity checking that --with-jvm-variants=minimal builds as some of this code is not compiled in with minimal VM builds.

Alan Bateman has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains five additional commits since the last revision:

 - Clarify Thread CPU time seciton of spec
 - Merge
 - Fix minimal build
 - Fix minimal build
 - Initial commit

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/12762/files
  - new: https://git.openjdk.org/jdk/pull/12762/files/c58765b3..7da35145

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=12762&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=12762&range=00-01

  Stats: 3492 lines in 187 files changed: 2307 ins; 454 del; 731 mod
  Patch: https://git.openjdk.org/jdk/pull/12762.diff
  Fetch: git fetch https://git.openjdk.org/jdk pull/12762/head:pull/12762

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


More information about the serviceability-dev mailing list