Capturing thread dumps without safepoints
David Phillips
david at acz.org
Mon Mar 5 22:48:58 UTC 2018
We often need to take thread dumps, using jstack or similar tools, and
would like to do so without the overhead of safepoints. This is
particularly important when the system is under heavy load, as we've seen
safepoints take 30+ seconds. Administrators often have the idea to
automatically capture a thread dump when the system becomes unhealthy, but
this can make the problem worse.
I had the idea to use AsyncGetCallTrace() to implement an asynchronous
version of jstack. It works as follows:
* Install a signal handler that captures the stack to a global memory
location.
* Register a ThreadStart event which captures the JNI environment and
pthread_t.
* Start an agent thread which accepts connections on a socket.
* When a client connects, it sends a signal to each thread using
pthread_kill() and writes out the stack trace after the signal handler
completes.
I would love to have feedback on the code: https://github.com/airlift/astack
Is this a reasonable approach? Is something like this already available in
the JVM?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/serviceability-dev/attachments/20180305/8f868864/attachment-0001.html>
More information about the serviceability-dev
mailing list