#!/usr/bin/env sent

# install sent with:
# git clone https://git.suckless.org/sent && cd sent && sudo make install

#Welcome

Choose a server to profile
- check top for activity
- open wavefront machine analysis
- check $(uname -r) before you start

# wget http://www.brendangregg.com/Perf/bcc_tracing_tools.png
@bcc_tracing_tools.png

# wget http://www.brendangregg.com/BPF/bpf_performance_tools_book.png
@bpf_performance_tools_book.png


\# For linux 4.4+
sudo perf record -F99 -a -g -- sleep 30
sudo perf script --header > stacks
-------------------------------------------------------
\# For linux 4.9+
sudo profile -F99 -df 30 > stacks

ctool scp d99-usw-2:stacks .
git clone https://github.com/brendangregg/FlameGraph.git && cd FlameGraph
./stackcollapse-perf.pl <stacks >collapsed #ONLY FOR PERF/DTRACE
./flamegraph.pl <collapsed >flamegraph.svg
open flamegraph.svg

kernel symbols?
- sudo apt install linux-image-$(uname -r)-dbgsym
- echo 0 | sudo tee /proc/sys/kernel/kptr_restrict
\
ubuntu package symbols?
- sudo apt install $(pkgname)-dbgsym

flamescope @ http://10.0.33.119:5000

refining the graphs
- filter by PID
- filter a given function call/syscall
- --color=js,java
- --color=io
- c++filt
\
./stackcollapse-perf.html < out.stacks | grep do_command | c++filt | \
    ./flamegraph.pl --color=io --title="Block I/O Flame Graph" --countname="I/O" > out.svg

#see http://www.brendangregg.com/blog/2014-11-09/differential-flame-graphs.html
"differential" flamegraphs
./difffolded.pl stacksA stacksB | ./flamegraph.pl > diff_flamegraph.svg

@tsa.png

@offcputracing-1000.png

"off-cpu" flamegraphs (man offcputime)
-> sudo offcputime -df > stacks
also hot/cold flamegraphs (on+off cpu)

"wakeup" flamegraphs
-> sudo wakeuptime -f > stacks
