Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Callgrind inlined functions

I am profiling my code and I already found the most expensive part of it. However it happens in an inlined function. To measure the impact I had forced the function to be not inlined.

Now I would like to report accurate profiling data. Without the inline we have a massive overhead (the function is basically a single loop, but it is called very, very often).

I wonder if it is possible to instruct valgrind to treat a specific section of the code as it were a function by itself (like the makros CALLGRIND_START_INSTRUMENTATION, CALLGRIND_STOP_INSTRUMENTATION) without forcing the function to not be inlined.

like image 392
ypnos Avatar asked Oct 23 '12 12:10

ypnos


1 Answers

valgrind --tool=callgrind

is able to show a lot of details about where the cpu (and other costs such as cache) is spent. kcachegrind (visualisation tool) can easily show the various costs (including for inlined functions).

Try to run e.g. with :

valgrind --tool=callgrind --dump-instr=yes --collect-jumps=yes 

Note: to look costs at instruction level, you must use kcachegrind

like image 169
phd Avatar answered Sep 30 '22 03:09

phd