A flame graph is a way of looking at a profile that turns thousands of sampled stack traces into a single readable picture. Brendan Gregg, who created it, describes it as a visualization of hierarchical data made to visualize stack traces of profiled software so that the most frequent code paths can be identified quickly and accurately. He released the technique and the supporting tools in December 2011.
The encoding is precise and worth stating carefully. Each rectangle is a stack frame. The y-axis is stack depth, counting up from zero at the bottom, so a box sitting on top of another box means it was called by the one below it. The x-axis is not time: it is the population of collected stacks, sorted alphabetically by function name, and the width of a frame is proportional to how often that frame was present in the sampled stacks. A wide box therefore means a function (and everything above it) accounted for a large share of the profile, which is exactly the place an engineer should look first. Because the ordering is alphabetical rather than chronological, identical sub-trees merge into single wide towers instead of scattering across the image.
Flame graphs are deliberately decoupled from any one profiler. As the FlameGraph repository documents, the workflow is three stages: capture stacks with a profiler such as Linux perf_events, DTrace, or FreeBSD pmcstat; fold the raw stacks with a stackcollapse program that compresses each unique stack into a single line with a count; and render that folded output into an interactive SVG with flamegraph.pl. Because the middle format is just text, the same renderer works across operating systems and languages, and the hard part is almost always getting good stacks in the first place rather than drawing the graph.
The idea spread far beyond Gregg’s original Perl scripts. Variants now include CPU flame graphs, off-CPU flame graphs that show time spent blocked rather than running, memory and allocation flame graphs, and differential flame graphs that color the change between two profiles. Interactive flame graph viewers are built into many language profilers, observability platforms, and even browser developer tools. The reason the visualization caught on is that it solved the readability problem of stack-sampling profilers: where a flat profile or a raw stack dump overwhelms, a flame graph makes the dominant path obvious in a single glance.