I am programming in C++ (on Linux) and I have recently started to use Valgrind/Callgrind to optimise my code. After reading a couple tutorials it seems that focusing on functions with highest 'self' cost is a good idea.
I found two functions with high self cost (they are both called >1M times and have >10% self cost each, relatively to the entire program execution time). In kcachegrind it shows:
Callgrind however does not tell me which part of the function make up for that self cost, making it difficult to optimise the code. What exactly is self cost and how can I attempt to reduce it?
My understanding/guess is that self cost includes reading/writing data, cache misses, basic maths operations, copying things in stack (including function arguments), etc. How do I know which one it is before I can address it?
Thanks