Slide 1

Slide 1 text

@mr_foto If you can read this you’re too close TBD

Slide 2

Slide 2 text

TO BE DETERMINED T B D @mr_foto

Slide 3

Slide 3 text

TO BE DETERMINED T B D

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

[YOU] [PARTY]

Slide 8

Slide 8 text

WHOIS ! Software Developer

Slide 9

Slide 9 text

WHOIS ! Software Developer " Ruby Slovenia organizer

Slide 10

Slide 10 text

WHOIS ! Software Developer " Ruby Slovenia organizer # Long Distance Runner

Slide 11

Slide 11 text

WHOIS ! Software Developer " Ruby Slovenia organizer # Long Distance Runner $ Event Photographer

Slide 12

Slide 12 text

WHOIS ! Software Developer " Ruby Slovenia organizer # Long Distance Runner $ Event Photographer ☕ Coffee Connoisseur

Slide 13

Slide 13 text

WHOIS ! Software Developer " Ruby Slovenia organizer # Long Distance Runner $ Event Photographer ☕ Coffee Connoisseur & Special

Slide 14

Slide 14 text

FLAME GRAPHS

Slide 15

Slide 15 text

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

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 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 20

Slide 20 text

MOAR EXPLAINING Function

Slide 21

Slide 21 text

MOAR EXPLAINING Function

Slide 22

Slide 22 text

MOAR EXPLAINING Stack Depth

Slide 23

Slide 23 text

MOAR EXPLAINING Stack Depth

Slide 24

Slide 24 text

MOAR EXPLAINING Stack Depth

Slide 25

Slide 25 text

MOAR EXPLAINING Ordered by Alphabet

Slide 26

Slide 26 text

MOAR EXPLAINING Total Time on CPU

Slide 27

Slide 27 text

MOAR EXPLAINING Total Time on CPU

Slide 28

Slide 28 text

Q&A Q: Which function is on CPU the most?

Slide 29

Slide 29 text

Q&A A: f() top edge shows what is on CPU directly

Slide 30

Slide 30 text

Q&A Q: Why is f() on CPU?

Slide 31

Slide 31 text

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

Slide 32

Slide 32 text

Q&A Q: How does b() compare to g()?

Slide 33

Slide 33 text

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

Slide 34

Slide 34 text

Q&A Q: Why are we running f()?

Slide 35

Slide 35 text

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

Slide 36

Slide 36 text

FOR REAL

Slide 37

Slide 37 text

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

Slide 38

Slide 38 text

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

Slide 39

Slide 39 text

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

Slide 40

Slide 40 text

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

Slide 41

Slide 41 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

Slide 42

Slide 42 text

No content

Slide 43

Slide 43 text

http://mr.si/
 @mr_foto THANK YOU http://rug.si/
 @RubySlovenia

Slide 44

Slide 44 text

No content