On 22/03/2023 17:23, Jonathan Ross wrote:
Hi Alan, and thanks for the response.
I would agree that naming virtual threads, particularly when using a VirtualThreadPerTaskExecutor, would not be that useful. No, what I'm actually asking is whether we could still fill in useful carrier thread information in the JFR events, and whether we could name the carrier threads. (I'm using the right term, I hope? The platform threads on which the virtual threads are run?)
Let me try to clarify the nameless thread bit. If I look at a flight recording running a large number of jobs using a VirtualThreadPerTaskExecutor, then the custom events I record that get fired on virtual threads don't have any thread information. If I look at the JMC threadview, I see all my custom events on a single row without a thread name. If I browse the event list, I also don't see any thread information.
I just tried looking at the raw data I captured using the jfr tool shipped with openjdk 20, but it fails:
jfr print: unexpected internal error, Pool jdk.types.StackTrace must contain at least one element java.lang.InternalError: Pool jdk.types.StackTrace must contain at least one element at jdk.jfr/jdk.jfr.internal.consumer.ChunkParser.fillConstantPools(ChunkParser.java:347) at jdk.jfr/jdk.jfr.internal.consumer.ChunkParser.<init>(ChunkParser.java:149) at jdk.jfr/jdk.jfr.internal.consumer.ChunkParser.nextChunkParser(ChunkParser.java:158) at jdk.jfr/jdk.jfr.consumer.RecordingFile.findNext(RecordingFile.java:252) at jdk.jfr/jdk.jfr.consumer.RecordingFile.readEvent(RecordingFile.java:111) at jdk.jfr/jdk.jfr.internal.tool.EventPrintWriter.print(EventPrintWriter.java:75) at jdk.jfr/jdk.jfr.internal.tool.Print.execute(Print.java:163) at jdk.jfr/jdk.jfr.internal.tool.Main.main(Main.java:87)
It looks like JMC isn't the only tool that gets confused by virtual threads in flight recordings.
I'm not aware of any issues or if the parsing exception in your mail is related to virtual threads or not, maybe hotspot-jfr-dev may recognize this. As a quick test, I tried some custom events committed from virtual threads and the jfr tool parses the recording, e.g. jfr print --events *Foo* ... Foo { startTime = 17:50:05.595 (2023-03-22) duration = 0.00147 ms message = "A message from a virtual thread" eventThread = "" (javaThreadId = 35, virtual) stackTrace = [ Test.lambda$main$0() line: 21 java.util.concurrent.FutureTask.run() line: 317 java.lang.VirtualThread.run(Runnable) line: 314 ] } Note the eventThread line has the thread name (empty in this case), the thread ID, and it also indicates that it is a virtual thread. -Alan
Okay, it must be something else causing the jfr problem, I'll contact jfr-dev as you suggest, thanks for that suggestion. Can you comment on jfr events not including information about the carrier thread? Is there any particular reason not to (want to) include platform thread information? I, for one, would like to be able to see the underlying fork-join scheduler at work in flight recordings. A second, somewhat related question: is it possible to use multiple distinct carrier thread pools, with different parallelism? (Perhaps there is some magic around creating virtual threads from within a forkjoin task?) Cheers, Jonathan On Wed, Mar 22, 2023 at 1:11 PM Alan Bateman <Alan.Bateman@oracle.com> wrote:
On 22/03/2023 17:23, Jonathan Ross wrote:
Hi Alan, and thanks for the response.
I would agree that naming virtual threads, particularly when using a VirtualThreadPerTaskExecutor, would not be that useful. No, what I'm actually asking is whether we could still fill in useful carrier thread information in the JFR events, and whether we could name the carrier threads. (I'm using the right term, I hope? The platform threads on which the virtual threads are run?)
Let me try to clarify the nameless thread bit. If I look at a flight recording running a large number of jobs using a VirtualThreadPerTaskExecutor, then the custom events I record that get fired on virtual threads don't have any thread information. If I look at the JMC threadview, I see all my custom events on a single row without a thread name. If I browse the event list, I also don't see any thread information.
I just tried looking at the raw data I captured using the jfr tool shipped with openjdk 20, but it fails:
jfr print: unexpected internal error, Pool jdk.types.StackTrace must contain at least one element java.lang.InternalError: Pool jdk.types.StackTrace must contain at least one element at
jdk.jfr/jdk.jfr.internal.consumer.ChunkParser.fillConstantPools(ChunkParser.java:347)
at
jdk.jfr/jdk.jfr.internal.consumer.ChunkParser.<init>(ChunkParser.java:149)
at
jdk.jfr/jdk.jfr.internal.consumer.ChunkParser.nextChunkParser(ChunkParser.java:158)
at jdk.jfr/jdk.jfr.consumer.RecordingFile.findNext(RecordingFile.java:252) at jdk.jfr/jdk.jfr.consumer.RecordingFile.readEvent(RecordingFile.java:111) at
jdk.jfr/jdk.jfr.internal.tool.EventPrintWriter.print(EventPrintWriter.java:75)
at jdk.jfr/jdk.jfr.internal.tool.Print.execute(Print.java:163) at jdk.jfr/jdk.jfr.internal.tool.Main.main(Main.java:87)
It looks like JMC isn't the only tool that gets confused by virtual threads in flight recordings.
I'm not aware of any issues or if the parsing exception in your mail is related to virtual threads or not, maybe hotspot-jfr-dev may recognize this.
As a quick test, I tried some custom events committed from virtual threads and the jfr tool parses the recording, e.g.
jfr print --events *Foo* ...
Foo { startTime = 17:50:05.595 (2023-03-22) duration = 0.00147 ms message = "A message from a virtual thread" eventThread = "" (javaThreadId = 35, virtual) stackTrace = [ Test.lambda$main$0() line: 21 java.util.concurrent.FutureTask.run() line: 317 java.lang.VirtualThread.run(Runnable) line: 314 ] }
Note the eventThread line has the thread name (empty in this case), the thread ID, and it also indicates that it is a virtual thread.
-Alan
On 22/03/2023 19:16, Jonathan Ross wrote:
Okay, it must be something else causing the jfr problem, I'll contact jfr-dev as you suggest, thanks for that suggestion.
Can you comment on jfr events not including information about the carrier thread? Is there any particular reason not to (want to) include platform thread information? I, for one, would like to be able to see the underlying fork-join scheduler at work in flight recordings. The scheduler threads are distinct and you may see some events committed on those threads. What would you do with the linkage if it was in the recording?
A second, somewhat related question: is it possible to use multiple distinct carrier thread pools, with different parallelism? (Perhaps there is some magic around creating virtual threads from within a forkjoin task?)
Not at this time. It will take time for the eco system to get used to virtual threads and in the future we can evaluate if are compelling reasons to allow for custom schedulers. -Alan
Hi Jonathan, There is an open bug related to missing threads in JFR [1]. It could be the issue, or it might something new for VT. We will take a look. Thanks for reporting. Today we record OS thread in the thread struct[2], maybe we could add the carrier/platform thread as well. It would allow JMC to render VTs in the thread view. Erik [1] https://bugs.openjdk.org/browse/JDK-8304033 [2] https://github.com/openjdk/jdk/blob/master/src/hotspot/share/jfr/metadata/me... [https://opengraph.githubassets.com/a5d3f73dbf47f40527cd2c8e76db552e72032595270113a4cd1943e26cc905ca/openjdk/jdk]<https://github.com/openjdk/jdk/blob/master/src/hotspot/share/jfr/metadata/metadata.xml#L1207> jdk/metadata.xml at master · openjdk/jdk<https://github.com/openjdk/jdk/blob/master/src/hotspot/share/jfr/metadata/metadata.xml#L1207> JDK main-line development https://openjdk.org/projects/jdk - jdk/metadata.xml at master · openjdk/jdk github.com [https://opengraph.githubassets.com/a5d3f73dbf47f40527cd2c8e76db552e72032595270113a4cd1943e26cc905ca/openjdk/jdk]<https://github.com/openjdk/jdk/blob/e73411a2354cf266ab7a5ddadfb6ea98d7eb4cd1/src/hotspot/share/jfr/metadata/metadata.xml#L1207> jdk/metadata.xml at e73411a2354cf266ab7a5ddadfb6ea98d7eb4cd1 · openjdk/jdk<https://github.com/openjdk/jdk/blob/e73411a2354cf266ab7a5ddadfb6ea98d7eb4cd1/src/hotspot/share/jfr/metadata/metadata.xml#L1207> JDK main-line development https://openjdk.org/projects/jdk - jdk/metadata.xml at e73411a2354cf266ab7a5ddadfb6ea98d7eb4cd1 · openjdk/jdk github.com [https://opengraph.githubassets.com/a5d3f73dbf47f40527cd2c8e76db552e72032595270113a4cd1943e26cc905ca/openjdk/jdk]<https://github.com/openjdk/jdk/blob/e73411a2354cf266ab7a5ddadfb6ea98d7eb4cd1/src/hotspot/share/jfr/metadata/metadata.xml#L1207> jdk/metadata.xml at e73411a2354cf266ab7a5ddadfb6ea98d7eb4cd1 · openjdk/jdk<https://github.com/openjdk/jdk/blob/e73411a2354cf266ab7a5ddadfb6ea98d7eb4cd1/src/hotspot/share/jfr/metadata/metadata.xml#L1207> JDK main-line development https://openjdk.org/projects/jdk - jdk/metadata.xml at e73411a2354cf266ab7a5ddadfb6ea98d7eb4cd1 · openjdk/jdk github.com Erik ________________________________ From: hotspot-jfr-dev <hotspot-jfr-dev-retn@openjdk.org> on behalf of Alan Bateman <Alan.Bateman@oracle.com> Sent: Wednesday, March 22, 2023 9:21 PM To: Jonathan Ross <jonathan.ross@cjug.org> Cc: hotspot-jfr-dev <hotspot-jfr-dev@openjdk.java.net>; loom-dev@openjdk.org <loom-dev@openjdk.org> Subject: Re: JFR integration On 22/03/2023 19:16, Jonathan Ross wrote:
Okay, it must be something else causing the jfr problem, I'll contact jfr-dev as you suggest, thanks for that suggestion.
Can you comment on jfr events not including information about the carrier thread? Is there any particular reason not to (want to) include platform thread information? I, for one, would like to be able to see the underlying fork-join scheduler at work in flight recordings. The scheduler threads are distinct and you may see some events committed on those threads. What would you do with the linkage if it was in the recording?
A second, somewhat related question: is it possible to use multiple distinct carrier thread pools, with different parallelism? (Perhaps there is some magic around creating virtual threads from within a forkjoin task?)
Not at this time. It will take time for the eco system to get used to virtual threads and in the future we can evaluate if are compelling reasons to allow for custom schedulers. -Alan
Hi Jonathan, The platform thread may change for a virtual thread, so it can be tricky to add support for it. Today, thread data are stored in a lookup table in the file and only the key is emitted with the event. This scheme is used to reduce the size of the recording. A better solution may be events when a virtual thread migrates, but first, why do you need the information? Cheers Erik ________________________________ From: hotspot-jfr-dev <hotspot-jfr-dev-retn@openjdk.org> on behalf of Jonathan Ross <jonathan.ross@cjug.org> Sent: Wednesday, March 22, 2023 8:16 PM To: Alan Bateman <alan.bateman@oracle.com> Cc: hotspot-jfr-dev <hotspot-jfr-dev@openjdk.java.net>; loom-dev@openjdk.org <loom-dev@openjdk.org> Subject: Re: JFR integration Okay, it must be something else causing the jfr problem, I'll contact jfr-dev as you suggest, thanks for that suggestion. Can you comment on jfr events not including information about the carrier thread? Is there any particular reason not to (want to) include platform thread information? I, for one, would like to be able to see the underlying fork-join scheduler at work in flight recordings. A second, somewhat related question: is it possible to use multiple distinct carrier thread pools, with different parallelism? (Perhaps there is some magic around creating virtual threads from within a forkjoin task?) Cheers, Jonathan On Wed, Mar 22, 2023 at 1:11 PM Alan Bateman <Alan.Bateman@oracle.com<mailto:Alan.Bateman@oracle.com>> wrote: On 22/03/2023 17:23, Jonathan Ross wrote:
Hi Alan, and thanks for the response.
I would agree that naming virtual threads, particularly when using a VirtualThreadPerTaskExecutor, would not be that useful. No, what I'm actually asking is whether we could still fill in useful carrier thread information in the JFR events, and whether we could name the carrier threads. (I'm using the right term, I hope? The platform threads on which the virtual threads are run?)
Let me try to clarify the nameless thread bit. If I look at a flight recording running a large number of jobs using a VirtualThreadPerTaskExecutor, then the custom events I record that get fired on virtual threads don't have any thread information. If I look at the JMC threadview, I see all my custom events on a single row without a thread name. If I browse the event list, I also don't see any thread information.
I just tried looking at the raw data I captured using the jfr tool shipped with openjdk 20, but it fails:
jfr print: unexpected internal error, Pool jdk.types.StackTrace must contain at least one element java.lang.InternalError: Pool jdk.types.StackTrace must contain at least one element at jdk.jfr/jdk.jfr.internal.consumer.ChunkParser.fillConstantPools(ChunkParser.java:347) at jdk.jfr/jdk.jfr.internal.consumer.ChunkParser.<init>(ChunkParser.java:149) at jdk.jfr/jdk.jfr.internal.consumer.ChunkParser.nextChunkParser(ChunkParser.java:158) at jdk.jfr/jdk.jfr.consumer.RecordingFile.findNext(RecordingFile.java:252) at jdk.jfr/jdk.jfr.consumer.RecordingFile.readEvent(RecordingFile.java:111) at jdk.jfr/jdk.jfr.internal.tool.EventPrintWriter.print(EventPrintWriter.java:75) at jdk.jfr/jdk.jfr.internal.tool.Print.execute(Print.java:163) at jdk.jfr/jdk.jfr.internal.tool.Main.main(Main.java:87)
It looks like JMC isn't the only tool that gets confused by virtual threads in flight recordings.
I'm not aware of any issues or if the parsing exception in your mail is related to virtual threads or not, maybe hotspot-jfr-dev may recognize this. As a quick test, I tried some custom events committed from virtual threads and the jfr tool parses the recording, e.g. jfr print --events *Foo* ... Foo { startTime = 17:50:05.595 (2023-03-22) duration = 0.00147 ms message = "A message from a virtual thread" eventThread = "" (javaThreadId = 35, virtual) stackTrace = [ Test.lambda$main$0() line: 21 java.util.concurrent.FutureTask.run() line: 317 java.lang.VirtualThread.run(Runnable) line: 314 ] } Note the eventThread line has the thread name (empty in this case), the thread ID, and it also indicates that it is a virtual thread. -Alan
participants (3)
-
Alan Bateman
-
Erik Gahlin
-
Jonathan Ross