java.lang.management, com.sun.management API and JVM TI only report Java threads.   The internal GC threads are not Java threads and are filtered.   There is no supported API to get the safepoint time and GC/compiler thread CPU time.

I also think that the internal thread CPU time/usage are useful to monitor.  It's worth considering exposing those statistics through com.sun.management API and/or via JFR.

Mandy

On 9/27/21 9:30 PM, Dylan Wragge wrote:
Hey serviceability devs,

I'm currently looking to migrate our company's codebases to JDK 17 and am running into an issue where sun.management.HotspotThreadMBean and HotspotRuntimeMBean are no longer accessible from client code. We have a few internal metrics that use this MBean in order to provide counters on safepoint time and internal thread (GC/Compiler/etc) CPU time/usage.

Safepoint time is nicely exposed as JFR events, which can be consumed easily with the streaming JFR API. Internal thread CPU time is proving difficult to access however. Other APIs I've tried seem to hide the existence of the GC threads altogether (which we are most interested in). So far I've tried JFR's ThreadCPUTime event and JVMTI's GetAllThreads/GetThreadInfo, both of which don't seem to include any of the internal GC threads. The MBean also does not seem to be registered by default, so seems totally inaccessible. Although even if it were, JEP 396 would stop me accessing any of its methods.

Is there a supported method in JDK 17 to get this information? To me this seems like a reasonable use case. In the past, we've found these metrics extremely useful when evaluating and tuning new GCs. I managed to get something working by scraping /proc but it feels like there should be a better (and more portable) way.

- Dylan

IMC Logo <https://www.imc.com/us/>

F <https://www.facebook.com/IMCTrading>

        

t <http://twitter.com/IMCTrading>

        

I <https://www.instagram.com/imctrading/>

        

in <https://www.linkedin.com/company/imc-financial-markets>

        

*imc.com* <https://www.imc.com/us/>

------------------------------------------------------------------------
The information in this e-mail is intended only for the person or entity to which it is addressed.

It may contain confidential and /or privileged material. If you are not the intended recipient, please notify us immediately and delete it from your system. Any other use or disclosure by you, including through automated tools operating on your systems is prohibited.

Reply via email to