RFR: 8299426: Heap dump does not contain virtual Thread stack references

Alex Menkov amenkov at openjdk.org
Tue Nov 14 23:26:11 UTC 2023


The change impelements dumping of unmounted virtual threads data (stack traces and stack references).
Unmounted vthreads can be detected only by iterating over the heap, but hprof stack trace records (HPROF_FRAME/HPROF_TRACE) should be written before HPROF_HEAP_DUMP/HPROF_HEAP_DUMP_SEGMENT.
HeapDumper supports segment dump (parallel dump to separate files with subsequent file merge outside of safepoint), the fix switches HeapDumper  to always use segment dump: 1st segment contains only non-heap data, other segments are used for dumping heap objects. For serial dumping single-threaded dumping is performed, but 2 segments are created anyway.
When HeapObjectDumper detects unmounted virtual thread, it writes HPROF_FRAME/HPROF_TRACE records to the 1st segment ("global writer"), and writes thread object (HPROF_GC_ROOT_JAVA_FRAME) and stack references (HPROF_GC_ROOT_JAVA_FRAME/HPROF_GC_ROOT_JNI_LOCAL) to the HeapObjectDumper segment.
As parallel dumpers may write HPROF_FRAME/HPROF_TRACE concurrently and VMDumper needs to write non-heap data before heap object dumpers can write virtual threads data, writing to global writer is protected with DumperController::_global_writer_lock.

-------------

Commit messages:
 - vthreads in heapdump

Changes: https://git.openjdk.org/jdk/pull/16665/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=16665&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8299426
  Stats: 308 lines in 3 files changed: 145 ins; 76 del; 87 mod
  Patch: https://git.openjdk.org/jdk/pull/16665.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/16665/head:pull/16665

PR: https://git.openjdk.org/jdk/pull/16665


More information about the serviceability-dev mailing list