Skip to content

Latest commit

 

History

History
55 lines (41 loc) · 1.7 KB

README.md

File metadata and controls

55 lines (41 loc) · 1.7 KB

Flame Graphs

Notes on producing Flame Graphs for Bitcoin Core.

This is based off some work originally done by Evan Klitzke.

Colouring

This directory includes a patch that will colour the graphs such that:

  • Yellow - Bitcoin Core
  • Blue - Boost
  • Green - LevelDB
  • Orange - System
  • Red - Everything else

Generating

# clone the Flame Graph repo
git clone https://github.com/brendangregg/FlameGraph && cd FlameGraph

# apply the bitcoin colouring patch
patch -p1 < path/to/core-review/flamegraph/bitcoin-colour.patch

# run bitcoind
./path/to/src/bitcoind

# capture 120s worth of stackframes using DTrace
# at 99 Hertz for the process named bitcoind
# 
# arg1 is the user-land program counter, so it's checked that it's non-zero.
# arg0 is the kernel.
# more info: http://www.brendangregg.com/FlameGraphs/cpuflamegraphs.html#Instructions
sudo dtrace -x ustackframes=100 \
-n 'profile-99 /execname == "bitcoind" && arg1/ { @[ustack()] = count(); } tick-120s { exit(0); }' \
-o out.stacks

./stackcollapse.pl out.stacks > out.folded
# check ./flamegraph.pl --help for more options
# i.e you prefer your graphs to hang from the ceiling pass --inverted
./flamegraph.pl out.folded --color bitcoin --title "Bitcoin Core" --width 1600 > out.svg

open out.svg

You can also filter the stack output before creating the graph:

./stackcollapse.pl out.stacks | \
grep -i 'ProcessMessage' | \
./flamegraph.pl --color bitcoin --title "Bitcoin Core" --width 1600 > out.svg

You should end up with graphs that look similar too this:

Flame Graph