Performance profiling#
If you are interested to know how much time is spent in different functions in your program, this is how to proceed.
Install
perf
(thelinux-perf
package for debian).If the package does not exist for your current kernel, a previous version can be used. Substitute the
perf
command toperf_4.9
if your kernel is 4.9).Either:
Run the node, find the pid.
Attach
perf
withperf record -p pid -F 99 --call-stack dwarf
.Then stop capturing with
Ctrl-C
. This can represent a lot of data. Don’t do that for too long. If this is too much you can remove the--call-stack dwarf
to get something more manageable, but interpreting the information can be harder.Let
perf
runoctez-node
:perf record -g -F 99 --call-graph=dwarf -- ./octez-node run ...
This will write the output in file
perf.data
after having stopped the node withCtrl-C
.
In both cases, the
-F
argument specifies the frequency of sampling of data (in hertz).If too much data is generated, use a smaller value. If data is not precise enough, try using a higher value.
display the result with
perf report
, or use a more advanced visualizer (recommended). Such visualizers include:flamegraph: command-line tool for generating flamegraphs (example for octez-node)
gprof2dot: command-line tool for generating callgraphs (example for octez-node)
hotspot: a GUI for the
perf
tool