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-perfpackage for debian).If the package does not exist for your current kernel, a previous version can be used. Substitute the
perfcommand toperf_4.9if your kernel is 4.9).Either:
Run the node, find the pid.
Attach
perfwithperf 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 dwarfto get something more manageable, but interpreting the information can be harder.Let
perfrunoctez-node:perf record -g -F 99 --call-graph=dwarf -- ./octez-node run ...This will write the output in file
perf.dataafter having stopped the node withCtrl-C.
In both cases, the
-Fargument 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
perftool