-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Perf Recording
Donald Sharp edited this page Oct 17, 2017
·
10 revisions
- Install Perf (make sure perf version matches kernel version)
- Install debug symbols for frr (for RHEL, frr-debuginfo)
- Run
perf top --call-graph=dwarf -p <pid>
to get a generic overview of the system. Screenshots of this are useful - Slightly more advanced usage:
perf record -g --call-graph=dwarf -- /usr/lib/frr/bgpd -A 127.0.0.1
then runvtysh -b
, and wait for whatever event. Kill -9 bgpd after you'd like to stop recording - If a routing daemon is already running you can tell perf to record a running process
perf record -g --call-graph=dwarf -p <pid>
- run perf with -K to hide kernel symbols so we can focus on bgpd, ospfd, or zebra daemon.
Some related interesting tools/techniques can be found at: http://gernotklingler.com/blog/gprof-valgrind-gperftools-evaluation-tools-application-level-cpu-profiling-linux/ and http://www.thegeekstuff.com/2012/08/gprof-tutorial
A good way to analyze (and share the data) is to convert the perf output to a Flamegraph. See https://github.com/brendangregg/FlameGraph for details on flamegraph.
- Do a
perf record
as outlined above (don't forget the-g
) - Convert the perf data and create graph:
- perf script > out.perf
- ./stackcollapse-perf.pl out.perf > out.folded
- ./flamegraph.pl out.folded > bgpd.svg
The svg file is a standalone file and can be best inspected with a webbrowser which supports svg (and the encoded scripts within the svg). Please note, that hovering the mouse over a block shows the full name (if only partially readable) and clicking on a block zooms into the specific function.