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

[Enhancement request] graalVM native image to show metrics for virtual thread, project loom #10478

Open
patpatpat123 opened this issue Jan 15, 2025 · 2 comments

Comments

@patpatpat123
Copy link

Hello team,

Thread observability is key for performance issue troubleshooting, production reliability, etc.

The jvm exposes metrics to help, which is great.

Since 21, there is the very cool project Loom.

However, the current set of metrics does not show anything related to project Loom and the virtual thread itself.

Would it be possible to provide assistance exposing metrics related to virtual threads?

Thank you

Image Image Image
@fniephaus
Copy link
Member

@roberttoyonaga are there any new JFR events or similar metrics for virtual threads that we should support in Native Image at some point?

@roberttoyonaga
Copy link
Collaborator

roberttoyonaga commented Jan 15, 2025

Currently, in Native Image, you can use jcmd to dump all virtual thread stacks using Thread.dump_to_file (See docs here). This is only in JDK 24 though (early access)

There are also already several JFR events which expose virtual thread information as of GraalVM for JDK 23 (docs here)

  • jdk.VirtualThreadEnd
  • jdk.VirtualThreadPinned
  • jdk.VirtualThreadStart

We're currently missing the jdk.VirtualThreadSubmitFailed JFR event. I'm not sure how useful this event is though. I can work on adding support for this if you'd like.

Additionally, JFR treats virtual threads the same as platform threads. So all of the existing JFR events we support also provide information on what virtual threads are doing. For example you can get jdk.JavaMonitorEnter events that are emitted from virtual threads. This tells you when a virtual thread is blocked at a monitor.

@patpatpat123 Are you using ThreadMXBean to generate those graphs? ThreadMXBean is currently only partially implemented in Native Image. I'm working on completing it, but I keep getting side-tracked by other tasks. In any case, it seems ThreadMXBean does not support virtual threads (see docs here).

If you have trouble using the above mentioned features please let me know, or file a bug report. If there are any other specific metrics that are missing from Native Image, please let me know as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants