How to build stack traces of specific threads with sample interval ± 100ms

There is OpenJDK8.
There is a pool of ExecutorService threads, for example, size 40.
The principle of operation is as follows:
1)a request has arrived, and a thread from the pool is taken to process it.
2)in the selected thread, we process the request
3) the thread is returned to the thread pool.
And so "in a circle".

Threads remain the same throughout the life of the JVM(thread names do not change, they are unique).

It is necessary to somehow understand what each of these threads was doing, with a frequency of sampling for example 100ms. In fact, just write all the stacktraces of the threads to a file.

Various profilers measure cpu, allocation, etc., aggregate threads, and remove idle threads. But I didn't find how to simply write stack traces.(I also watched Andrey Pangin's async-profiler).

With the exception of SJK from Alexey Rogozin, but despite the fact that I specified the refresh rate -i 100ms, the withdrawal occurred approximately once per second and the RMI thread consumed one CPU core per second. 90%.

Author: srg321, 2020-02-05

1 answers

Async-profiler in wall clock mode does exactly what you need.

profiler.sh -e wall -i 100ms -d 60 -f out.jfr PID
  • -e wall selects the wall clock mode (sampling all threads)
  • -i 100ms sets the interval
  • -d 60 duration of profiling in seconds
  • -f out.jfr write non-aggregated data in JFR format, which can then be opened in Java Mission Control

Recently, a fix was committed to the thread-filter branch, which dynamically selects the frequency sampling to maintain the specified interval as accurately as possible, regardless of the number of threads.

 0
Author: apangin, 2020-02-07 20:01:17