On Thu, 21 Sep 2023 20:06:13 GMT, Alex Menkov <amen...@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] > jdk.internal.vm.Continuation.enterSpecial(Ljdk/internal/vm/Continuatio... Is there anything to tell you which carrier thread is associated with which mounted VThread? test/lib/jdk/test/lib/hprof/model/Root.java line 145: > 143: > 144: public long getReferrerId() { > 145: return refererId; Spelling: `referrerId` test/lib/jdk/test/lib/hprof/model/ThreadObject.java line 9: > 7: * published by the Free Software Foundation. Oracle designates this > 8: * particular file as subject to the "Classpath" exception as provided > 9: * by Oracle in the LICENSE file that accompanied this code. Test files do not use the CPE. test/lib/jdk/test/lib/hprof/model/ThreadObject.java line 33: > 31: > 32: private final long id; // ID of the JavaThing we refer to > 33: // private JavaHeapObject referer = null; Remove this? test/lib/jdk/test/lib/hprof/parser/HprofReader.java line 917: > 915: System.out.println("WARNING: " + msg); > 916: } > 917: /* Should this be deleted? ------------- PR Comment: https://git.openjdk.org/jdk/pull/15869#issuecomment-1736839223 PR Review Comment: https://git.openjdk.org/jdk/pull/15869#discussion_r1338149011 PR Review Comment: https://git.openjdk.org/jdk/pull/15869#discussion_r1338149626 PR Review Comment: https://git.openjdk.org/jdk/pull/15869#discussion_r1338149989 PR Review Comment: https://git.openjdk.org/jdk/pull/15869#discussion_r1338150749