RFR: JDK-8316691: Heap dump: separate stack traces for mounted virtual threads [v3]
Leonid Mesnik
lmesnik at openjdk.org
Fri Oct 6 19:18:06 UTC 2023
On Fri, 29 Sep 2023 02:20:10 GMT, Alex Menkov <amenkov at openjdk.org> wrote:
>> This is subtask of JDK-8299426: Heap dump does not contain virtual Thread stack references
>> The change:
>> - reorganize thread-related code/prepare it to use for unmounted vthreads:
>> - new ThreadDumper class caches stack frames, thread serial num, frame serial number (trace serial number is calculated from thread serial);
>> ThreadDumper objects for all platform/carrier and mounted virtual threads are cached instead of ThreadStackTrace objects (they are created during HPROF_FRAME/HPROF_TRACE dumping, used lated for writing HPROF_GC_ROOT_THREAD_OBJ/HPROF_GC_ROOT_JAVA_FRAME/HPROF_GC_ROOT_JNI_LOCAL subrecords);
>> - new helper class JavaStackRefDumper to dump references from threadf stack;
>> - separate track traces for mounted virtual threads:
>> - separate HPROF_FRAME/HPROF_TRACE records for mounted vthreads and carrier threads;
>> - separate HPROF_GC_ROOT_THREAD_OBJ/HPROF_GC_ROOT_JAVA_FRAME/HPROF_GC_ROOT_JNI_LOCAL subrecords;
>> - updated hprof parser test lib to collect data about threads (HPROF_GC_ROOT_THREAD_OBJ subrecords) and corresponding stack traces and stack references.
>>
>> Testing - tier1-tier3, new test
>>
>> Output of the test for VtreadInHeapDumpTarg$VthreadMounted thread
>> without the fix:
>> `thread 0x8101be90, 16 frames
>> - [0] VtreadInHeapDumpTarg$VthreadMounted.run()V (VtreadInHeapDump.java:127)
>> Java Local Reference: VtreadInHeapDumpTarg$VthreadMounted
>> Java Local Reference: VtreadInHeapDumpTarg$VThreadMountedReferenced
>> - [1] java.lang.Thread.runWith(Ljava/lang/Object;Ljava/lang/Runnable;)V (Thread.java:1583)
>> Java Local Reference: java.lang.VirtualThread
>> Java Local Reference: java.lang.Class
>> Java Local Reference: VtreadInHeapDumpTarg$VthreadMounted
>> - [2] java.lang.VirtualThread.run(Ljava/lang/Runnable;)V (VirtualThread.java:309)
>> Java Local Reference: java.lang.VirtualThread
>> Java Local Reference: VtreadInHeapDumpTarg$VthreadMounted
>> Java Local Reference: java.lang.Class
>> - [3] java.lang.VirtualThread$VThreadContinuation$1.run()V (VirtualThread.java:190)
>> Java Local Reference: java.lang.VirtualThread$VThreadContinuation$1
>> - [4] jdk.internal.vm.Continuation.enter0()V (Continuation.java:320)
>> Java Local Reference: java.lang.VirtualThread$VThreadContinuation
>> - [5] jdk.internal.vm.Continuation.enter(Ljdk/internal/vm/Continuation;Z)V (Continuation.java:312)
>> Java Local Reference: java.lang.VirtualThread$VThreadContinuation
>> - [6] jd...
>
> Alex Menkov has updated the pull request incrementally with one additional commit since the last revision:
>
> misspell getRefererId for consistency
The fix looks good. (I looked at the test changes mostly.) The only question, if it makes sense to update the test to verify that heapdump works correctly without continuations.
-------------
Marked as reviewed by lmesnik (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/15869#pullrequestreview-1662657247
More information about the serviceability-dev
mailing list