Skip to content

Commit 4878b02

Browse files
committed
more examples
1 parent a77864d commit 4878b02

5 files changed

+4945
-22
lines changed

README.md

+50-22
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Example (click to zoom):
66
[![Example](http://brendangregg.github.io/FlameGraph/cpu-bash-flamegraph.svg)](http://brendangregg.github.io/FlameGraph/cpu-bash-flamegraph.svg)
77

88
Other sites:
9-
- CPU profiling using Linux perf_events, DTrace, SystemTap, or ktap: http://www.brendangregg.com/FlameGraphs/cpuflamegraphs.html
9+
- CPU profiling using Linux perf\_events, DTrace, SystemTap, or ktap: http://www.brendangregg.com/FlameGraphs/cpuflamegraphs.html
1010
- CPU profiling using XCode Instruments: http://schani.wordpress.com/2012/11/16/flame-graphs-for-instruments/
1111
- CPU profiling using Xperf.exe: http://randomascii.wordpress.com/2013/03/26/summarizing-xperf-cpu-usage-with-flame-graphs/
1212
- Memory profiling: http://www.brendangregg.com/FlameGraphs/memoryflamegraphs.html
@@ -20,11 +20,11 @@ Flame graphs can be created in three steps:
2020

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

25-
### Linux perf_events
25+
### Linux perf\_events
2626

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

2929
```
3030
# perf record -F 99 -a -g -- sleep 60
@@ -114,16 +114,38 @@ $ grep cpuid out.kern_folded | ./flamegraph.pl > cpuid.svg
114114

115115
Provided Example
116116
================
117-
An example output from DTrace is included, both the captured stacks and
118-
the resulting Flame Graph. You can generate it yourself using:
117+
118+
### Linux perf\_events
119+
120+
An example output from Linux "perf script" is included, gzip'd, as example-perf-stacks.txt.gz. The resulting flame graph is example-perf.svg:
121+
122+
[![Example](http://brendangregg.github.io/FlameGraph/example-perf.svg)](http://brendangregg.github.io/FlameGraph/example-perf.svg)
123+
124+
You can create this using:
125+
126+
```
127+
gunzip -c example-perf-stacks.txt.gz | ./stackcollapse-perf.pl --kernel | ./flamegraph.pl --color=java --hash > example-perf.svg
128+
```
129+
130+
This shows my typical workflow: I'll gzip profiles on the target, then copy them to my laptop for analysis. Since I have hundreds of profiles, I leave them gzip'd!
131+
132+
Since this profile included Java, I used the flamegraph.pl --color=java palette. I've also used stackcollapse-perf.pl --kernel, which allows a separate color to be used for kernel code. The resulting flame graph uses: green == Java, yellow == C++, red == user-mode native, orange == kernel.
133+
134+
This profile was from an analysis of vert.x performance. The benchmark client, wrk, is also visible in the flame graph.
135+
136+
### DTrace
137+
138+
An example output from DTrace is also included, example-dtrace-stacks.txt, and the resulting flame graph, example-dtrace.svg:
139+
140+
[![Example](http://brendangregg.github.io/FlameGraph/example-dtrace.svg)](http://brendangregg.github.io/FlameGraph/example-dtrace.svg)
141+
142+
You can generate this using:
119143

120144
```
121145
$ ./stackcollapse.pl example-stacks.txt | ./flamegraph.pl > example.svg
122146
```
123147

124-
This was from a particular performance investigation: the Flame Graph
125-
identified that CPU time was spent in the lofs module, and quantified
126-
that time.
148+
This was from a particular performance investigation: the Flame Graph identified that CPU time was spent in the lofs module, and quantified that time.
127149

128150

129151
Options
@@ -132,19 +154,25 @@ See the USAGE message (--help) for options:
132154

133155
USAGE: ./flamegraph.pl [options] infile > outfile.svg
134156

135-
--titletext # change title text
136-
--width # width of image (default 1200)
137-
--height # height of each frame (default 16)
138-
--minwidth # omit smaller functions (default 0.1 pixels)
139-
--fonttype # font type (default "Verdana")
140-
--fontsize # font size (default 12)
141-
--countname # count type label (default "samples")
142-
--nametype # name type label (default "Function:")
143-
--colors # "hot", "mem", "io" palette (default "hot")
144-
--hash # colors are keyed by function name hash
145-
--cp # use consistent palette (palette.map)
146-
eg,
147-
./flamegraph.pl --titletext="Flame Graph: malloc()" trace.txt > graph.svg
157+
--title # change title text
158+
--width # width of image (default 1200)
159+
--height # height of each frame (default 16)
160+
--minwidth # omit smaller functions (default 0.1 pixels)
161+
--fonttype # font type (default "Verdana")
162+
--fontsize # font size (default 12)
163+
--countname # count type label (default "samples")
164+
--nametype # name type label (default "Function:")
165+
--colors # set color palette. choices are: hot (default), mem, io,
166+
# java, js, perl, red, green, blue, yellow, purple, orange
167+
--hash # colors are keyed by function name hash
168+
--cp # use consistent palette (palette.map)
169+
--reverse # generate stack-reversed flame graph
170+
--inverted # icicle graph
171+
--negate # switch differential hues (blue<->red)
172+
--help # this message
173+
174+
eg,
175+
./flamegraph.pl --title="Flame Graph: malloc()" trace.txt > graph.svg
148176

149177
As suggested in the example, flame graphs can process traces of any event,
150178
such as malloc()s, provided stack traces are gathered.
File renamed without changes.

example.svg example-dtrace.svg

File renamed without changes.

example-perf-stacks.txt.gz

108 KB
Binary file not shown.

0 commit comments

Comments
 (0)