Using Valgrind for profiling olsrd

  • warning: Illegal string offset 'data' in /var/www/ on line 110.
  • warning: Illegal string offset 'data' in /var/www/ on line 110.

Valgrind is a powerful tool for performance and correctness analysis of code. This page discusses how to set your development environment up, such that you can profile a running olsr daemon and later analyze its recordings using a graphical frontend called Kcachegrind.

First patch your makefile such that the debug symbols are not removed after compilation

diff -r 26494c58ff86
--- a/ Wed Jan 09 22:01:18 2008 +0100
+++ b/ Thu Jan 10 14:46:27 2008 +0100
@@ -5,10 +5,10 @@
# activate debugging with 1 or deactivate with 0
-DEBUG ?= 0
+DEBUG ?= 1
# compile OLSR_PRINTF out

Next run valgrind with the following command line options.

valgrind --tool=callgrind -v --dump-instr=yes --trace-jump=yes ./olsrd -d 0 -nofork

Finally load kcachgrind to display the profiling data. (watch out the callgrind data are written with a umask of 600 as user root - so you may want to chown or chmod the file, otherwise kcachegrind cannot open your data and will display an empty screen)

Attached you find a screenshoot of profiling 30minutes olsrd at home.
The most noteworthy result from that profiling session is, that we soon need to rewrite
the timer library plus the entire Hello input path processing.

kcachegrind-screenshot.jpg218.48 KB