graal icon indicating copy to clipboard operation
graal copied to clipboard

Add support for ManagementFactory.getThreadMXBean().dumpAllThreads()

Open mhalbritter opened this issue 3 years ago • 5 comments

Right now, ManagementFactory.getThreadMXBean().dumpAllThreads() throws a com.oracle.svm.core.jdk.UnsupportedFeatureError. Would be great if it could really do a thread dump.

GraalVM: 22.1

mhalbritter avatar Jul 11 '22 15:07 mhalbritter

Any chances of this getting implemented? It would help a lot with debugging performance problems.

theotherp avatar Feb 19 '24 06:02 theotherp

Any chances of this getting implemented? It would help a lot with debugging performance problems.

If you are looking into time spend on CPU, I would suggest using perf on Linux. See https://www.graalvm.org/latest/reference-manual/native-image/debugging-and-diagnostics/DebugInfo/ .

NOTE: I did get better results with -H:+PreserveFramePointer instead of -g. When using FP, you would use perf record --call-graph=fp ..., which is actually the default. For -g, you would use perf record --call-graph=dwarf ....

SergejIsbrecht avatar Feb 19 '24 10:02 SergejIsbrecht

Thanks for the advice, but my use case is somewhat different. I've developed a program for end users which I converted to Native Image. Previously when debugging performance issues I could have them just click a button which would log the stack trace in the log and they could send the log to me. Now asking them to run per inside a docker container is a bit more complex :-)

theotherp avatar Feb 19 '24 10:02 theotherp

I guess as an alternative you could use Thread.getAllStackTraces() to write everything out to a file?

SergejIsbrecht avatar Feb 19 '24 15:02 SergejIsbrecht

Didn't know that would work with graal, will try it out. Thanks!

Why would this work but not the other call? I wouldve thought it's basically the same.

On Mon, 19 Feb 2024, 16:33 SergejIsbrecht, @.***> wrote:

I guess as an alternative you could use Thread.getAllStackTraces() to write everything out to a file?

— Reply to this email directly, view it on GitHub https://github.com/oracle/graal/issues/4714#issuecomment-1952707537, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADNUA6OEI7XJI7T546UWQWLYUNWDLAVCNFSM53H27XMKU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOJVGI3TANZVGM3Q . You are receiving this because you commented.Message ID: @.***>

theotherp avatar Feb 19 '24 18:02 theotherp

For Spring Actuator it's the same, it uses ManagementFactory.getThreadMXBean().dumpAllThreads(true, true) to dump all threads. As long as this is not supported it is unfortunately unable to provide the thread dump Actuator functionality.

cmdjulian avatar Feb 20 '24 09:02 cmdjulian