Collect data for a flame graph

Sample all CPUs at 99 Hz for 30 seconds and save the stacks for a flame graph

perf record -F 99 -ag -- sleep 30 && perf script > out.perf

tool
perf17 commands
tags
perfprofilingflamegraph

More perf commands

  • perf stat -e syscalls:sys_enter_read ./my_app

    Count how many read() syscalls the app makes

  • perf record -p 1234 sleep 5

    Profile a process that is already running for 5 seconds

  • perf top -g --call-graph dwarf

    Live view of hot functions with their callers; dwarf unwinding works without frame pointers

  • perf record -F 99 -a -g -- sleep 30 && perf report --stdio

    Sample the whole machine at 99 Hz for 30 seconds and print a text report; 99 Hz avoids sampling in lockstep with timers

  • perf script | stackcollapse-perf.pl | flamegraph.pl > flame.svg

    Turn perf.data into an interactive flame graph SVG with Brendan Gregg's FlameGraph tools

all 17 perf commands