Build a flame graph

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

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

tool
perf17 commands
tags
perfperformanceobservabilitytroubleshooting

More perf commands

  • perf stat -d -d -d -- ./app

    Three -d flags add L1, LLC, TLB and stalled-cycle details, so you can see if the app waits on memory or on CPU

  • perf sched record -- sleep 10 && perf sched latency --sort max

    Record context switches and show wakeup latency per task to find tasks waiting too long in the run queue

  • perf trace -s -p <pid>

    Trace syscalls like strace and print a summary with -s; lower overhead because it does not use ptrace

  • perf probe --add 'tcp_sendmsg size' && perf record -e probe:tcp_sendmsg -a -- sleep 5

    Add a kprobe that captures an argument and record it, so you can look inside the kernel without rebuilding it

  • perf record -g ./my_app

    Record performance data with call graphs

all 17 perf commands