4.12. Call Stack

Freja records information about how functions in the application call each other. The chain of functions leading up to a point of interest is called a call stack.

The call stack tells you which functions have called which to reach the point in the program you are looking at. This is useful to know when trying to reduce the number of calls to a function that causes large numbers of cache misses.

Freja augments source code and instruction listings in the report with call stack information, and visualizes the different call stacks in the source code annotation by color coding them differently.

A function may behave differently when called from different locations. It may for example work well when called with a small data set from one location, but behave badly when called with a larger data set from another location. Freja therefore optionally uses the call stack information to separate different call sites from each other and give individual advice for the function when called from each call site.

The number of levels of calling functions used to differentiate between call sites is called the call stack depth. The call stack depth used in the analysis can be varied to suit your application. By default Freja uses a call stack depth of 1, that is, only the innermost calling function is considered in the analysis.

A lower call stack depth reduces the number of reported issues by merging different call sites. A call stack depth of 0 will completely disregard where functions are called from. A higher call stack depth generally increases the number of issues and their accuracy, but may also make the report harder to overview.

When attaching to a running process, the sampler does not have complete knowledge of the call stack at that point. This may result in several contexts being evaluated; one for each discovered version of the callstack. The same thing can happen when burst-sampling the application. The recommendation for these cases is to reduce the depth of the call stack begin part of the analysis.