A low-overhead Python tracer that records function calls and visualizes code execution as an interactive timeline.
flamegraph-rs/flamegraph
A Rust-based flamegraph generator that profiles Cargo projects or any binary using perf, xctrace, or dtrace/blondie, without Perl.
- Stars
- 6,053
- Forks
- 194
- Open issues
- 75
- Last commit
- 5 days ago
What is it?
flamegraph generates flamegraphs to show where a program spends its time. It works with Cargo projects through the cargo flamegraph subcommand, and it can also profile any binary or an already running process by PID. Stack samples are collected with the platform's native tool and rendered as an interactive SVG built on the Inferno library.
The tool runs on Linux using perf, on macOS using xctrace, and on Windows using the blondie library or DTrace when it is installed. It offers options for choosing the build profile, binary, example, benchmark or test target, sampling frequency, color palette, and custom perf or dtrace commands.
The README also includes a guide to reading flamegraphs and a set of notes on performance measurement, such as the USE Method and advice on benchmarking before optimizing.
Key features
- 01Profiles Cargo projects, binaries, examples, benchmarks, and tests via cargo flamegraph.
- 02Attaches to running processes by PID.
- 03Uses perf on Linux, xctrace on macOS, and blondie or DTrace on Windows.
- 04Writes an interactive SVG that can be opened in a browser.
- 05Supports custom perf or dtrace command options and several color palettes.
- 06Provides shell completion for the flamegraph binary in bash, fish, zsh, powershell, and elvish.
Use cases
- Finding hot functions in a Rust application before optimizing it.
- Profiling a C or C++ binary without installing Perl or building pipelines by hand.
- Comparing where time is spent in a benchmark or test run.
- Profiling an already running service by attaching to its process ID.
Quick start
- 1
Install the flamegraph binaries with Cargo
cargo install flamegraph - 2
Profile a Rust project
cargo flamegraph - 3
Profile an arbitrary binary
flamegraph -- /path/to/binary
Things to know
- Profiling depends on platform tools: perf on Linux, xctrace on macOS, and blondie or dtrace on Windows.
- On Linux with lld (default since Rust 1.90.0) or mold, you must add the --no-rosegment linker flag or stack traces may be inaccurate.
- Unprivileged perf use may require lowering perf_event_paranoid, which weakens system security.
In collections
Topics
FAQ
- What is flamegraph?
- A Rust-based flamegraph generator that profiles Cargo projects or any binary using perf, xctrace, or dtrace/blondie, without Perl. flamegraph generates flamegraphs to show where a program spends its time. It works with Cargo projects through the cargo flamegraph subcommand, and it can also profile any binary or an already running process by PID. Stack samples are collected with the platform's native tool and rendered as an interactive SVG built on the Inferno library.
- Is flamegraph free to use? What license does it have?
- flamegraph is open source under the Apache-2.0 license. Check the license terms before using it in commercial products.
- Is flamegraph still maintained?
- Actively maintained. The last commit to flamegraph was on Nov 2, 2026.
- What can I use flamegraph for?
- Finding hot functions in a Rust application before optimizing it. Profiling a C or C++ binary without installing Perl or building pipelines by hand. Comparing where time is spent in a benchmark or test run. Profiling an already running service by attaching to its process ID.
- How do I install flamegraph?
- Install the flamegraph binaries with Cargo: cargo install flamegraph Profile a Rust project: cargo flamegraph Profile an arbitrary binary: flamegraph -- /path/to/binary
- Where can I get flamegraph?
- The source code and installation instructions are on GitHub: https://github.com/flamegraph-rs/flamegraph
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
A low-overhead, zero-instrumentation frame stack sampler for CPython, written in C, for profiling running Python processes.
A free Windows tool for isolating CPU and memory performance problems, with special support for investigating .NET runtime code.
Open-source tracing and profiling suite with SDKs, system daemons and a browser-based UI for analyzing traces on Android, Linux and Chromium.
A Task Manager replacement for Windows and Linux that shows deep per-process detail such as threads, memory, handles, sockets and modules.
A standalone command-line tool that watches files and directories and runs a command whenever they change.