HP PAK Performance Analysis Tools User's Guide

22 Chapter 2
Puma Concepts
How Puma Analyzes Recursive Procedures
(This analysis uses the raw count for clarity; the percentage or parent
percentage would not reflect a strictly accurate picture, as the
percentages are approximations. The in-only raw counts of the nested
procedures add up to the in-or-under raw count of 6 for main.)
This analysis, although correct, does not properly summarize the
program's behavior. It does not show that three of the six stack traces are
of the form main [r…] r and three are of the form main [r…] s.
Recursion collapsing remedies this. When you request recursion
collapsing, Puma does not make a new node in a tree of call chains if it
encounters a recursive call. Instead Puma creates a recursive stub that
represents the recursion and refers to the place higher up the call chain
where the same routine occurs. Puma then jumps up in the tree to that
point and continues playing out the stack trace. In effect, call chains are
truncated. The following sample analysis presents a collapse of the
recursion in the earlier example.
Samples Samples
In or Under In Only
Raw Count Raw Count Level
----------- --------- ------
6 0 1 main
632r
1 (2) 3 3 s
3 r...
The first line of this analysis is the same as the earlier one. The second
line, for r, shows all three main [r…] r calls attributed in the in-only
column to r, since levels have been collapsed. The third line shows three
samples attributed to s. The notation 1 (2) indicates one sample at this
level and two at lower levels. In other words, there were three stack
traces that passed through this point in the tree; one got there directly
through the ancestors as shown, while two got there after some skipping
through the recursive stubs. Note that only in-or-under data is split up
according to whether recursive stubs were traversed; the in-only data is
not. The fourth line, r…, represents the recursive stub. It indicates that
the parent routine (r at Level 2) called the child (r at Level 3), and a stub
was built pointing up to the parent.