-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
The description for live VT metrics is not accurate:
Line 48 in e4d5d00
| private static final String LIVE_THREADS_DESCRIPTION = "Approximate current number of virtual threads that are unfinished"; |
These metrics are based on
jdk.management.VirtualThreadSchedulerMXBean:
/**
* {@return an estimate of the number of virtual threads that are currently
* <i>mounted</i> by the scheduler; {@code -1} if not known}
*
* <p> The number of mounted virtual threads is equal to the number of platform
* threads carrying virtual threads.
*
* @implNote This method may overestimate the number of virtual threads that are mounted.
*/
int getMountedVirtualThreadCount();
/**
* {@return an estimate of the number of virtual threads that are queued to
* the scheduler to start or continue execution; {@code -1} if not known}
*
* @implNote This method may overestimate the number of virtual threads that are
* queued to execute.
*/
long getQueuedVirtualThreadCount();
So they only reflect the VT scheduler status (pending tasks to be executed and ongoing tasks), for example VT waiting for I/O are out of the scope of this metric.
Months ago, I created this #5950, to request a metric more accurate to the current description of live VT's ("Approximate current number of virtual threads that are unfinished").
In conclusion, the current metrics do not provide information about the current VT's created but not finished. For example, this metric could help check if an application is being overwhelmed and is creating more VT's than it is closing. The required changes were made in this PR, so if you're interested it should be easy to add the metric.