The good news: there is a βscriptβ for working with jstacks in the FlameGraph repository.
https://github.com/brendangregg/FlameGraph
This is stackcollapse-jstack.pl .
It seems that by default it only expects a stack trace after a stack trace at its input and considers each of them to be a "fetch point".
That way, you can just do a few jstack in a file (run this one or more times, or once per second "for a while", etc.):
jstack pid_of_your_jvm >> my_jstack
Then run this script:
./stackcollapse-jstack.pl my_jstack > my_jstack.folded
and finally convert to flameograph:
./flamegraph.pl
No third-party helpers are required (although they can still be useful).
Also note that non-RUNNABLE threads are discarded in the stackcollapse-jstack.pl file, you can configure it if you also want to enable βunoccupiedβ threads (this is usually not the case).
Apparently you can use the linux "perf" command to generate stacks for the Java process, and also see README https://github.com/brendangregg/FlameGraph
This may include more of your own calls, for example.
source share