Slide 1

Slide 1 text

FLAME GRAPHS

Slide 2

Slide 2 text

WHY AND WHAT • How SW is consuming CPU • DTrace is verbose and unreadable • Brendan Gregg • combine stack traces with common paths

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

FLAME GRAPHS EXPLAINED • each box represents a function (a merged stack frame) • y-axis (vertical) shows stack depth • top function led directly to the profiling event • everything beneath it is ancestry (explains why) • x-axis (horizontal) shows the sample sorted alphabetically • box width shows the total time it was on-CPU

Slide 6

Slide 6 text

LOOKS

Slide 7

Slide 7 text

TUTORIAL Q: Which function is on CPU the most?

Slide 8

Slide 8 text

TUTORIAL A: f() top edge shows who is on CPU directly

Slide 9

Slide 9 text

TUTORIAL Q: Why is f() on CPU?

Slide 10

Slide 10 text

TUTORIAL A: a() → b() → c() → e() → f() f() was called by e(), e() was called by c(),…

Slide 11

Slide 11 text

TUTORIAL Q: How does b() compare to g()?

Slide 12

Slide 12 text

TUTORIAL A: b() looks like it is running (present) about 10 times more often than g()

Slide 13

Slide 13 text

TUTORIAL Q: Why are we running f()?

Slide 14

Slide 14 text

TUTORIAL A: code path branches can reveal key functions:
 a() choose the b() path
 c() choose the e() path look for branches

Slide 15

Slide 15 text

REAL WORLD EXAMPLE • Sam Saffron • gem 'flamegraph' Flamegraph.generate(filename) do # your work here end

Slide 16

Slide 16 text

1.083 (± 0.0%) i/s - 33.000 in 30.861265s ORIGINAL

Slide 17

Slide 17 text

8.368 (±12.0%) i/s - 244.000 in 30.037836s | 7.5x improvement CACHE KRAMDOWN

Slide 18

Slide 18 text

10.140 (± 9.9%) i/s - 292.000 in 30.025553s | 9.4x improvement MEMOIZATION & CO.

Slide 19

Slide 19 text

FURTHER READ • The Flame Graph: http://queue.acm.org/ detail.cfm?id=2927301 • flamegraph gem: https://github.com/SamSaffron/ flamegraph • rack-mini-profiler: https://github.com/ MiniProfiler/rack-mini-profiler • ruby-prof-flamegraph: https://github.com/oozou/ ruby-prof-flamegraph