cd perf-jitdump-agent
mvn package
# Create a directory named jitdump in the project home directory with scripts and libraries
cd target
make install
The agent can either be loaded on JVM start or attached to an already running JVM.
When loading the agent the following options are available and can be set on the command line.
verbose=[0-5] 0 is off, and 5 is trace level, by default logging is off.
directory=<PATH> Location to store JitDump file, byt default $HOME/.debug/jit.
duration=<seconds> How long to record method compilation to the jitdump file, by default infinite (-1).
When attaching to an already running JVM use <PATH>/jitdump/bin/jitdump -p <PID>
, the attach mechanism supports the
same options as when loading the agent, run <PATH>/jitdump/bin/jitdump -h
for details.
- Start Java application (and load agent if you want to be able to start recording directly).
- For correct stack unwinding and maximum information available for the agent add the following options.
-XX:+PreserveFramePointer -XX:+UnlockDiagnosticVMOptions -XX:+DebugNonSafepoints
- Instead of
-XX:+PreserveFramePointer
the perf recording can on modern hardware use the-call-graph lbr
option to gather stack traces.
- Ensure that duration is infinite or longer than your intended recording to ensure all compiled methods are registered correctly.
- For correct stack unwinding and maximum information available for the agent add the following options.
- Attach agent unless loaded at start,
<PATH>/jitdump/bin/jitdump -p <PID>
- Ensure that duration is infinite or longer than your intended recording to ensure all compiled methods are registered correctly.
perf record -g -k 1 -p <PID>
perf inject -j -i perf.data -o perf.jit.data
- Unpack your Java source code to the current directory to enable
perf report
to find it correctly.- Don't forget
<JAVA_HOME>/src.zip
- Don't forget
perf report --source --no-children -i perf.jit.data
Not all distributions will support the -j/--jit flag with the shipped version of perf. On Ubuntu 16.04 for example, the
man page mentions the flag but the binary does not recognize it. However the recording can still be done with the
version shipped with the distribution, but the inject step requires a self compiled binary with support for the jit
option. Compiling perf is rather straight forward, pull the latest Linux source code and enter the the
linux/tools/perf
directory and run make
. Depending on your system you might need to install one or more required
libraries for a successful compilation.
This program is licensed under GPLv2. See the LICENSE file.