<div dir="ltr"><div>Hi, </div><div><br></div><div>I am working on a JVMTI agent and currently try to get a good estimate on the total amount of CPU time consumed by the VM for GC. </div><div><br></div><div>I already found out about sun.management:type=HotspotThreading and InternalThreadCpuTimes. Unfortunately this does not work for G1 which fails to deliver metrics for the following threads:</div><div>* G1 Main Concurrent Mark GC Thread</div><div>* G1 Parallel Marking Threads</div><div>* G1 Concurrent Refinement Thread<br></div><div><br></div><div>I suspect this has to do with the current implementation of G1CollectedHeap::gc_threads_do which differs from G1CollectedHeap::print_gc_threads_on (jstack shows all G1 related threads).</div><div><br></div><div>Is this a bug or somehow difficult to change? Is there a better way to get CPU times from internal VM threads from native code in my agent? The JVMTI operation <span style="color:rgb(0,0,0)">GetAllThreads unfortunately does not return internal threads. I can think of one possible solution that parses output of thread dumps (</span><font color="#000000">VM_PrintThreads) to detect native thread IDs of GC related threads and determine thread CPU time this way.</font></div><div><font color="#000000"><br></font></div><div><font color="#000000">Thank you for any comments and hints,</font></div><div>Markus Gaisbauer (Dynatrace)</div></div>