Flamegraphs
Purpose
Guide agents through the pipeline from profiler data to SVG flamegraph, and teach interpretation of flamegraphs to drive concrete optimisation decisions.
Triggers
- "How do I generate a flamegraph from perf data?"
- "How do I read a flamegraph?"
- "The flamegraph shows a wide frame — what does that mean?"
- "How do I generate a flamegraph from Callgrind?"
- "I want to compare two flamegraphs (before/after)"
Workflow
1. Install FlameGraph tools
2. perf → flamegraph (most common path)
One-liner:
3. Differential flamegraph (before/after)
4. Callgrind → flamegraph
5. Other profiler inputs
6. Reading flamegraphs
A flamegraph is a call-stack visualisation:
- X axis: time on CPU (not time sequence) — wider = more time
- Y axis: call stack depth — taller = deeper call chain
- Color: random (no significance) — unless using differential mode
What to look for:
Identifying the actionable hotspot:
- Find the widest top frame (a frame with no or narrow children above it)
- That is where CPU time is actually spent
- Trace down to understand what called it and why
Differential flamegraph:
- Red frames: more time in new profile (regression)
- Blue frames: less time in new profile (improvement)
- Frames only in one profile appear solid colored
7. flamegraph.pl options
References
For tool installation, stackcollapse scripts, and palette options, see references/tools.md [blocked].
Related skills
- Use
skills/profilers/linux-perfto collect perf data - Use
skills/profilers/valgrindto collect Callgrind data - Use
skills/compilers/clangfor LLVM PGO from sampling profiles


