Permalink
Browse files

Generate flame graphs from the 'perf' profile.

This is less helpful than expected on both oil.ovm-dbg and oil.ovm-opt.

It works at a function level, and the interpreter loop is in a single
function with a big switch statement.
  • Loading branch information...
Andy Chu
Andy Chu committed Mar 6, 2018
1 parent c221ee4 commit 857eb4df9f838d78939bc168a355ea1f9ffcf35c
Showing with 29 additions and 1 deletion.
  1. +29 −1 benchmarks/perf.sh
View
@@ -62,6 +62,7 @@ debug-symbols() {
#
# Wow.
# Maybe I need counters in optimized mode?
# Yeah what I really want is per opcode total!
_record() {
@@ -70,7 +71,15 @@ _record() {
# work?
#perf record -o perf.data -- _bin/oil.ovm-dbg osh -n benchmarks/testdata/abuild | wc -l
perf record -o perf.data -- _bin/oil.ovm-opt osh --ast-format none -n benchmarks/testdata/abuild
# call graph recording. This helps it be less "flat" in opt mode. Otherwise
# everything is PyEval_EvalFrameEx.
local flag='-g'
local bin=_bin/oil.ovm-opt
# This shows more details
#local bin=_bin/oil.ovm-dbg
perf record $flag -o perf.data -- $bin osh --ast-format none -n benchmarks/testdata/abuild
#perf record -o perf.data -- _bin/osh --ast-format none -n benchmarks/testdata/abuild
}
record() { sudo $0 _record; }
@@ -82,6 +91,10 @@ record() { sudo $0 _record; }
# After recording, run perf-data, then 'perf report'. It automatically shows
# perf.data.
report() {
perf report -n --stdio "$@"
}
_perf-data() {
# This gets run as root
chmod 644 perf.data
@@ -99,4 +112,19 @@ _stat() {
}
stat() { sudo $0 _stat; }
# NOTE: I used this before with python-flamegraph too.
flamegraph() {
~/git/other/FlameGraph/flamegraph.pl "$@"
}
stackcollapse-perf() {
~/git/other/FlameGraph/stackcollapse-perf.pl "$@"
}
# http://www.brendangregg.com/FlameGraphs/cpuflamegraphs.html
make-graph() {
perf script | stackcollapse-perf > out.perf-folded
flamegraph out.perf-folded > perf-kernel.svg
}
"$@"

0 comments on commit 857eb4d

Please sign in to comment.