Pro Yearly is on sale from $80 to $50! »

What Are Flame Graphs and How To Read Them

5a5fcbae333f071dc7a28f4958509db5?s=47 Miha Rekar
December 22, 2014

What Are Flame Graphs and How To Read Them

Short tech talk I did for my coworkers on flame graphs.

Further read:
- Blazing Performance with Flame Graphs (video): https://www.usenix.org/conference/lisa13/technical-sessions/plenary/gregg
- FlameGraph: https://github.com/brendangregg/FlameGraph
- ruby-prof: https://github.com/ruby-prof/ruby-prof
- ruby-prof-flamegraph: https://github.com/oozou/ruby-prof-flamegraph

5a5fcbae333f071dc7a28f4958509db5?s=128

Miha Rekar

December 22, 2014
Tweet

Transcript

  1. WHAT ARE FLAME GRAPHS AND HOW TO READ THEM

  2. DEFINITION • each box represents a function (a merged stack

    frame) • y-axis shows stack depth • top function led directly to the profiling event • everything beneath it is ancestry (explains why) • x-axis spans the sample population, sorted alphabetically • box width is proportional to the total time a function was profiled directly or its children were profiled • all threads can be shown in the same Flame Graph (the default), or as separate per-thread Flame Graphs • flame graphs can be interactive: mouse over for details
  3. LOOKS • Flame Graphs sort stacks alphabetically • from the

    bottom frame upwards • increases merging and visualizes code paths
  4. EXAMPLE Q: Which function is on CPU the most?

  5. EXAMPLE A: f() top edge shows who is on CPU

    directly
  6. EXAMPLE Q: Why is f() on CPU?

  7. EXAMPLE A: a() → b() → c() → e() →

    f() f() was called by e(), e() was called by c(),…
  8. EXAMPLE Q: How does b() compare to g()?

  9. EXAMPLE A: b() looks like it is running (present) about

    10 times more often than g()
  10. EXAMPLE Q: Why are we running f()?

  11. EXAMPLE A: code path branches can reveal key functions:
 a()

    choose the b() path
 c() choose the e() path look for branches
  12. FURTHER READ • FlameGraph: https://github.com/ brendangregg/FlameGraph • ruby-prof: https://github.com/ruby-prof/ ruby-prof

    • ruby-prof-flamegraph: https://github.com/ oozou/ruby-prof-flamegraph