Skip to content

VT's metrics #6703

@ceremo

Description

@ceremo

The description for live VT metrics is not accurate:

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions