We are asked this question sometimes, especially when customers profile real world UI applications. Since it may be really confusing, I’ve decided to post the explanation of this “phenomena”.
The Caller/Callee is one of views that are generated by Microsoft Visual Studio Team System 2005 during application profiling. The view is described in details in “Analyzing a performance report in Visual Studio Team System 2005 Part 2: The Function, Caller / Callee and Calltree views” posting or in “Make Your Apps Fly with the New Enterprise Performance Tool” MSDN article.
Why do we see callees that sum up with more than 100% of Inclusive Percent samples?
That I can tell you in one word – recursion.
Let’s try to analyze the following simple code.
void A(bool CallB)
Actually, this code doesn’t have a pure recursion – no function calls itself. As you can see, the program will block itself having the following call stack:
main à A à B à A à C
So, function A appears more than once on the stack. Let me refer to this as some sort of recursion. The interesting point here is that function A calls different functions each time (first time it calls B, and second time it calls C)
Sample profiling of this application gives us the expected Call Tree view:
We also get the following Caller/Callee view (showing functions called by A and functions calling A):
We see that B and main are callers of A, while B and C are also callees (called by A).
Well, apparently it does. Let’s try to analyze the data we got.
The above scenario is artificial. Real life scenarios, however, may have some variation of the recursion pattern that we discussed, thus generating profiling data that may confuse at the beginning. I hope this explanation makes it clearer.