Fix bug generating flame graphs with deep stacks #164
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When a stack becomes too deep, the flame graph reporter cuts off the
stack and just displays a node with
<STACK TOO DEEP>
as the name. Upuntil now, all such nodes would share the same dict of child nodes. This
was usually fine, because we should never attempt to add child nodes
below a node that was already too deep. However, subtly, if there were
several different call stacks that led to the too-deep node, and they
differed only in ignored CPython-internal frames, and they had
a different number of ignored frames, then it was possible that the same
node in our tree, when reached by two different paths, would be found at
two different depths. If a later call found the same node at a shallower
depth, we would try to add children to it, modifying the children of all
of the too-deep nodes.
Fix both of these problems. Stop assigning the same dict to every
too-deep node, and instead just use the empty dict of children that it
already holds. Also, stop counting skipped frames towards our depth
limit. This removes any risk of us adding nodes below a node that was
already too deep in the future, and also ensures that all of the marker
nodes for a truncated stack appear at the same depth in the flame graph.
Closes: #163