explaingit

flamegraph-rs/flamegraph

5,920RustAudience · developerComplexity · 2/5Setup · moderate

TLDR

flamegraph is a Rust command-line tool that profiles any program and generates an interactive SVG chart showing which functions are consuming the most CPU time, integrated directly into the cargo build system.

Mindmap

mindmap
  root((flamegraph))
    What it does
      Profiles programs
      Generates SVG charts
      Shows CPU hotspots
    Tech stack
      Rust
      cargo subcommand
      System profilers
    Use cases
      Rust binary profiling
      Benchmark analysis
      Live process attach
    Audience
      Rust developers
      Performance engineers
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 Rust binary with a single cargo flamegraph command and get an interactive SVG showing which functions are slowest

USE CASE 2

Profile a Rust benchmark suite to catch performance regressions before they ship

USE CASE 3

Attach to an already-running process by its PID to generate a live CPU flamegraph without restarting it

Tech stack

Rustcargo

Getting it running

Difficulty · moderate Time to first run · 30min

Linux users must install a system perf package separately and may need to adjust the perf_event_paranoid kernel setting to allow profiling.

No license information is mentioned in the description.

In plain English

flamegraph is a command-line tool for generating flamegraphs, which are visual charts that show where a program is spending its CPU time. In a flamegraph, each function call in the program appears as a horizontal bar. The wider the bar, the more time the CPU spent in that function. Bars are stacked to show which functions called which, so you can trace a slow path from the top-level code down to the specific operation taking time. The output is an interactive SVG file you can open in a browser. The tool works by running your program under a system profiler (perf on Linux, xctrace on macOS, or a built-in library on Windows), collecting stack traces at regular intervals, and then converting those traces into the flamegraph image. It is written in Rust but can profile any executable, not just Rust programs. For Rust developers, there is a cargo subcommand called cargo-flamegraph that integrates with the standard Rust build system. You can run cargo flamegraph instead of cargo run and the tool handles compiling with the right debug settings, running the binary under the profiler, and producing the output file. It also works with benchmarks, tests, examples, and already-running processes (by attaching to a process ID). Installation is via cargo install flamegraph. Linux users need to install a system perf package separately, macOS and Windows support is built in. The README includes troubleshooting notes for common linker configurations that can cause incorrect profiling results on newer Linux toolchains.

Copy-paste prompts

Prompt 1
Run cargo flamegraph on my Rust binary and explain how to read the resulting SVG to find the function using the most CPU time
Prompt 2
How do I use cargo flamegraph to profile a specific Rust benchmark by name and open the flamegraph in my browser?
Prompt 3
I have a slow Rust web server running in production. How do I attach flamegraph to the process by PID and generate a CPU flamegraph?
Open on GitHub → Explain another repo

← flamegraph-rs on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.