JVM Symbol Table for Linux Perf

CPU profiling with Linux perf can help identify functions for investigation. To be able to translate memory addresses into readable function and variable names Linux perf uses a symbol table for the program. For JIT compiled languages the symbol table is created at compile time and stored in memory. An example of how to create this for a JVM running in a container using jcmd is shown below.

# use jcmd to create a symbol table for the JVM
jcmd 123456 Compiler.perfmap

# use nsenter to collect the map file from the /tmp container the JVM is running in
# create a copy of this map file in /tmp on the host that perf will be run on
# rename the file with the pid of the container
nsenter -t 123456 -a cat /tmp/perf-1.map > /tmp/perf-123456.map

# run perf
perf record -p 123456 -g -- sleep 10

perf report can be used to navigate and analyse the perf.data file produced.

perf report

This will now show class and method names in the CPU stack trace sample.