explaingit

brendangregg/flamegraph

19,473PerlAudience · ops devopsComplexity · 3/5Setup · moderate

TLDR

FlameGraph turns raw CPU profiler output into an interactive SVG chart where the widest boxes show which functions consume the most time, making it fast to spot performance bottlenecks in any program.

Mindmap

mindmap
  root((FlameGraph))
    What it does
      Visualize CPU usage
      Interactive SVG output
      Stack trace analysis
    Three-step process
      Capture perf data
      Collapse stacks
      Render SVG
    Profiler support
      Linux perf
      DTrace
      Java and Go
    Use cases
      Debug slow services
      Optimize code
      Share findings
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Profile a slow production service with Linux perf, then generate a flame graph to pinpoint exactly which functions are the CPU bottleneck.

USE CASE 2

Optimize a Go or Java application by visualizing call stacks and clicking into the widest bars that represent the most time-consuming code paths.

USE CASE 3

Share an interactive SVG flame graph with a colleague so they can zoom in and search for specific functions in a browser without installing any tools.

Tech stack

Perl

Getting it running

Difficulty · moderate Time to first run · 1h+

Requires a compatible profiler such as Linux perf or DTrace already installed and configured on your system.

In plain English

FlameGraph is a tool that turns raw performance profiling data into a visual chart, called a flame graph, that makes it instantly clear where a program is spending most of its time. The problem it solves is performance diagnosis: when a program is slow, developers need to know which function calls are eating CPU time, but raw profiler output is a wall of numbers that is very hard to read. A flame graph stacks those function calls visually so that the widest boxes at the top are the biggest time consumers. The process has three steps. First, you capture stack samples from your running program using a profiler like Linux perf, DTrace, or SystemTap, tools that periodically snapshot what the CPU is doing. Second, a "stackcollapse" script reformats those raw samples into a tidy text format. Third, the main flamegraph.pl script takes that text and renders an interactive SVG image you can open in a browser, zoom into by clicking, and search with Ctrl-F to find specific functions. You would reach for this tool when a production service is slow and you need to find the root cause quickly, or when optimizing code and you want proof of which areas are worth improving. It supports profiling data from Linux perf, DTrace, SystemTap, Java, Go, Instruments, VTune, and more. The core script is written in Perl.

Copy-paste prompts

Prompt 1
Walk me through the full process of profiling a Node.js process on Linux using perf, then running the brendangregg/flamegraph stackcollapse scripts and flamegraph.pl to produce an interactive SVG.
Prompt 2
I have a slow Python web service. Show me how to capture a CPU profile using py-spy and pipe the output through brendangregg/flamegraph to create a visual flame graph.
Prompt 3
Help me write a shell script that automates all three flamegraph steps for a given PID: capture perf data for 30 seconds, collapse the stacks, and render the SVG output file.
Prompt 4
I generated a flame graph SVG from my Go service. Explain what the width and height of each box mean and how I should read it to find the root cause of slowness.
Open on GitHub → Explain another repo

← brendangregg on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.