Documentation ¶
Overview ¶
Perf2pprof converts Linux perf profile data into Go pprof format. (The Linux perf suite is sometimes referred to as perf_events.)
usage: perf2pprof [-list] [-o outfile] [-x exe] perf.data
Perf2pprof converts perf.data, generated by the Linux perf suite, into pprof format. The default output file name is the input file name (including any directory) with .pprof appended. The -o flag instructs perf2pprof to write to outfile instead.
Perf is a system-wide profiler for Linux: it captures data from every binary running on the system, along with the operating system kernel. Although in principle it should be possible to express those multiple event sources in a single pprof output file, the current perf2pprof is limited to extracting the samples from just one executable that was running. The -x flag specifies the executable, typically a full path. The -list flag causes perf2pprof to list all the executables with samples in the profile. One of -list or -x must be specified.
Go and Perf ¶
By default, Go does not maintain x86 frame pointers, which means that perf cannot sample from Go's execution reliably. To build a Go 1.5 or later toolchain that works with perf, use:
GOEXPERIMENT=framepointer ./make.bash
Bugs ¶
This is a very rough sketch. It does seem to work for simple perf profiles tracking only a single event, but it could be made much richer.
It should not be necessary to specify the -x flag, as explained above. Even if limited to one executable's samples, perf2pprof could infer the correct setting for -x by reading the profile to count samples per executable, set -x to the executable with the most samples, and read the profile again.