Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add metrics related to virtual threads #9619

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

tjquinno
Copy link
Member

@tjquinno tjquinno commented Dec 23, 2024

Description

Resolves #9533

Helidon exposes new meters related to virtual thread usage:

  • current number of active virtual threads (disabled by default)
  • total number of virtual thread starts (disabled by default)
  • total number of pinned threads
  • distribution summary (history) of pinned threads
  • number of failed attempts to submit virtual threads to platform threads

The virtual thread count meters are disabled by default for performance reasons. Enable them by setting metrics.virtual-threads.count.enabled=true in configuration, but be aware doing so can degrade the server's performance.


The PR adds a new MetersProvider implementation to the helidon-metrics-system-meters component. The new implementation registers for selected Java Flight Recorder events to track data related to virtual threads.

The three meters enabled by default should be rare so monitoring the JFR events for them adds very little overhead. In contrast, to maintain the current number of active virtual threads and the total number of virtual thread starts the added code must register for and respond to virtual thread start and end events which can be costly. That's why those two meters--and the registration of listeners for those events from JFR--are disabled by default.

Documentation

Small additions to the SE and MP metrics guide and doc pages.

@tjquinno tjquinno self-assigned this Dec 23, 2024
@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Dec 23, 2024
@spericas
Copy link
Member

spericas commented Jan 2, 2025

Some general questions @tjquinno ...

  • current number of active virtual threads (disabled by default)
  • total number of virtual thread starts (disabled by default)
  • total number of pinned threads

Is there also a counter for platform threads?

  • distribution summary (history) of pinned threads

Do you have an example?

  • number of failed attempts to submit virtual threads to platform threads

Under what conditions would this counter be incremented?


listenFor(rs, Map.of("jdk.VirtualThreadStart", this::recordThreadStart,
"jdk.VirtualThreadEnd", this::recordThreadEnd));
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also track non-virtual thread start/end? Or is that already available elsewhere?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCA Verified All contributors have signed the Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Evaluate adding metrics for virtual threads
2 participants