brendangregg /FlameGraph

Stack trace visualizer

★ 19,834⑂ 2,110👁 469⑃ 203● 156▤ 1
Download: First Tagged Release (19-Aug-2017)First-1.0 ↓1.02017-08-19
+1
Daily
19,834
stars
2,110
forks
469
watchers
203
prs
156
issues
1
releases

README

Flame Graphs visualize profiled code

Main Website: http://www.brendangregg.com/flamegraphs.html

Example (click to zoom):



Click a box to zoom the Flame Graph to this stack frame only.
To search and highlight all stack frames matching a regular expression, click the _search_ button in the upper right corner or press Ctrl-F.
By default, search is case sensitive, but this can be toggled by pressing Ctrl-I or by clicking the _ic_ button in the upper right corner.

Other sites:
- The Flame Graph article in ACMQ and CACM: http://queue.acm.org/detail.cfm?id=2927301 http://cacm.acm.org/magazines/2016/6/202665-the-flame-graph/abstract
- CPU profiling using Linux perf\_events, DTrace, SystemTap, or ktap: http://www.brendangregg.com/FlameGraphs/cpuflamegraphs.html
- CPU profiling using XCode Instruments: http://schani.wordpress.com/2012/11/16/flame-graphs-for-instruments/  
- CPU profiling using Xperf.exe: http://randomascii.wordpress.com/2013/03/26/summarizing-xperf-cpu-usage-with-flame-graphs/  
- Memory profiling: http://www.brendangregg.com/FlameGraphs/memoryflamegraphs.html  
- Other examples, updates, and news: http://www.brendangregg.com/flamegraphs.htmlUpdates

Flame graphs can be created in three steps:

1. Capture stacks
2. Fold stacks
3. flamegraph.pl

1\. Capture stacks
=================
Stack samples can be captured using Linux perf\_events, FreeBSD pmcstat (hwpmc), DTrace, SystemTap, and many other profilers. See the stackcollapse-\ converters.

 Linux perf\_events

Using Linux perf\_events (aka "perf") to capture 60 seconds of 99 Hertz stack samples, both user- and kernel-level stacks, all processes:


 perf record -F 99 -a -g -- sleep 60
 perf script  out.perf


Now only capturing PID 181:


 perf record -F 99 -p 181 -g -- sleep 60
 perf script  out.perf


 DTrace

Using DTrace to capture 60 seconds of kernel stacks at 997 Hertz:


 dtrace -x stackframes=100 -n 'profile-997 /arg0/ { @[stack()] = count(); } tick-60s { exit(0); }' -o out.kern_stacks


Using DTrace to capture 60 seconds of user-level stacks for PID 12345 at 97 Hertz:


 dtrace -x ustackframes=100 -n 'profile-97 /pid == 12345 && arg1/ { @[ustack()] = count(); } tick-60s { exit(0); }' -o out.user_stacks


60 seconds of user-level stacks, including time spent in-kernel, for PID 12345 at 97 Hertz:


 dtrace -x ustackframes=100 -n 'profile-97 /pid == 12345/ { @[ustack()] = count(); } tick-60s { exit(0); }' -o out.user_stacks


Switch ustack() for jstack() if the application has a ustack helper to include translated frames (eg, node.js frames; see: http://dtrace.org/blogs/dap/2012/01/05/where-does-your-node-program-spend-its-time/).  The rate for user-level stack collection is deliberately slower than kernel, which is especially important when using jstack() as it performs additional work to translate frames.

2\. Fold stacks
==============
Use the stackcollapse programs to fold stack samples into single lines.  The programs provided are:

- stackcollapse.pl: for DTrace stacks
- 

Top issues

Latest release

First Tagged Release (19-Aug-2017) v1.0 2017-08-19
I'm adding a tagged release to FlameGraph so that package maintainers can grab a static version. There's nothing really special about this v1.0 release, other than it reflecting a stable body of code that is in widespread use, and recently merged a number of fixes.

Recent changes/fixes include:

- fixing a small floating point issue with search's total percent which is now more accurate 140 
- stackcollapse-perf.pl now supports multiple event sources 136 
- fixing a title overlap issue with large --height 125
- adding an optional subtitle (--subtitle) https://github.com/brendangregg/Fl

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON