[Enhancement request] graalVM native image to show metrics for virtual thread, project loom
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
@roberttoyonaga are there any new JFR events or similar metrics for virtual threads that we should support in Native Image at some point?
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.
Hello @roberttoyonaga @patpatpat123 ,
What is the status of this?
I am using SpringBoot + Micrometer in my project, and have JVM metrics enabled.
I +1 @roberttoyonaga idea. But I cannot see any metrics related jdk.VirtualThreadEnd jdk.VirtualThreadPinned jdk.VirtualThreadStart.
I am using graalVM 24
What is the status of this?
I am using SpringBoot + Micrometer in my project, and have JVM metrics enabled.
I +1 @roberttoyonaga idea. But I cannot see any metrics related jdk.VirtualThreadEnd jdk.VirtualThreadPinned jdk.VirtualThreadStart.
I am using graalVM 24
Hi @ryleighmikami do you have the jdk.VirtualThreadEnd jdk.VirtualThreadPinned jdk.VirtualThreadStart events defined in your JFR configuration file (.jfc file)? jdk.VirtualThreadEnd and jdk.VirtualThreadStart are disabled by default. You need to enable them in your .jfc file. Additionally, virtual threads do not pin for exactly the same reasons in Native Image as they do in Java. So you may not see jdk.VirtualThreadPinned events when you expect them.
Is jcmd Thread.dump_to_file working for you?