Profiling JVM using perf
perf is often used to profile C/C++ programs but kind of falls short for JVM programs due to the dynamic nature of
JIT. Fortunately, newer versions of perf do have special support for JIT in JVM via JVMTI. (One probably needs to
build perf themselves, as many Linux distributions don’t enable JVMTI by default; the important file is
libperf-jvmti.so.)
This note records some commands I often use while profiling JVM using perf.
- recording a run
1 | perf record \ |
- inject JIT data
1 | perf inject -i perf.data --jit -o perf.data.jitted |
- reading the report
1 | perf report -Mintel -G -i perf.data.jitted |
View the assembly (pressing a) and check for the hottest instructions (pressing H).