Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to interpret results from kcachegrind

Tags:

Could anyone tell me how to interest the results from kcachegrind.

I had two versions of my code (v1, v2) both compiled in debug mode. I ran them through valgrind with options:

valgrind --tool=callgrind -v ....

The output files thus generated are opened in kcachegrind. Now I already found the version v2 of the code runs more faster than first version, v1 as it meant to be. But how do i inperet a result from kcachegrind's call graph.

In kcachegrind All Callers tab, I have the following columns: Incl. , Distance, Called, Caller.

IIUC, Called and caller are the no of times the 'caller' was called in the program. But I dont know about others.

Another thing is when selecting a particular function and then the 'callers' tab it shows some more information. Ir, Ir per call, count, caller and in the types tab: `EventType, Incl. Self, short, Formula.

I dont have any idea here.

So far I had read these questions:

KCachegrind interpretation confusion Confused about profiling result

like image 591
rkm Avatar asked May 21 '14 14:05

rkm


People also ask

What is incl in KCacheGrind?

Incl. is the inclusive cost of a function, this means the function itself and all it's including functions. Self is only the cost of the function itself. Types shows the Event types, typically only Hits.

How do I start KCacheGrind?

You can launch KCacheGrind using command line or in the program menu if your system installed it here. Then, you have to open your profile file. The first view present a list of all the profiled functions. You can see the inclusive and the self cost of each function and the location of each one.


1 Answers

I use QCacheGrind, so I apologize if something on my screen isn't quite the same as what you see. From what I understand, QCacheGrind is a direct Qt port of KCacheGrind. Additionally, I have the ability to toggle between an Instruction Count and a % of total instructions. For consistency I will refer to the Instruction Count view on any column that can be toggled in this way.

The "All Callers" tab columns should represent the following:

  • Incl.: The number of instructions that this function generated as a whole broken down by each caller. Because callers are a hierarchy (hence the distance column) there may be several that have the same value if your call stack is deep.

  • Distance: How many function calls separated is the selected line from the function that is selected in the Flat Profile panel.

  • Called: The number of time the Caller called the a function that ultimately led to the execution of the selected function).

  • Caller: The function that directly called or called another caller of your selected function (as determined by Distance).

The Callers tab is more straightforward. It shows the functions that have a distance of 1 from your selected function. In other words, these are the functions that directly invoke your selected function.

  • Ir: The number of instructions executed in total by the selected function after being called by this caller.

  • Ir per call: The number of instructions executed per call.

  • Count: The number of times the selected function was called by the caller.

  • Caller: The function that directly called the selected function.

For Events, see this page for the handbook. I suspect that if you didn't define your own types all you should see is "Instruction Fetch" and possibly "Cycle Estimation." The quick breakdown on these columns is as follows:

  • Incl.: Again the total instructions performed by this function and all functions it calls beneath it.

  • Self: The instructions performed exclusively by this function. This counter only tracks instructions used by this function, not any instruction used by functions that are called by this function.

  • Short and Formula: These columns are used when defining a custom Event Type. Yours should either be blank or very short (like CEst = Ir) unless you end up defining your own Types.

like image 123
Joe Burzinski Avatar answered Nov 09 '22 23:11

Joe Burzinski