fix(inspector): count each recursive call once, not once per enclosing call - #960
Merged
lcottercertinia merged 1 commit intoAug 25, 2026
Conversation
A selection whose occurrences nest, which is any recursive method, took each occurrence as a root and walked its whole subtree, so an inner call was walked once per enclosing call. Bottom Up read 12,781 calls for a method the grid counts 1,998 times, and the totals rose with it. A total now sums the outermost occurrences only, matching how the grids already sum theirs. Self time never nests, so it and the call count still cover every occurrence, which makes the new Avg self row a true per-call figure.
lcottercertinia
approved these changes
Aug 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The inspector inflated every figure for a recursive method. Selecting a method the Analysis grid counts 1,998 times gave a Bottom Up call count of 12,781, with the times raised in step, so the panel disagreed with the grid the user had just clicked.
An aggregate selection took each occurrence as a root and walked its whole subtree. For a recursive frame an occurrence sits inside another, so it was walked once per enclosing call. The fix sums the outermost occurrences only, which is how the grids already sum theirs. Self time never nests, so it and the call count still cover every occurrence.
Changes
scopedCallTreedrops occurrences that sit inside another selected one, so a frame is walked once. This also fixes the Bottom Up call count, which the same root set feeds.EventVitalstakes its Time total fromsumDurationTotalForRootEvents, the helper the bottom-up grid uses for the same figure, so the two agree.Avgrow becomesAvg self: total self time over the call count. Both count the same calls, so the figure is a true per-call reading, and it matches the grids' existing Avg Self Time columns.Test plan
pnpm testscopedCallTree.test.ts: an aggregate of nested occurrences totals the outer call alone, and counts both calls once.EventVitals.test.ts: a self-calling method totals the outermost call and averages the self time of every call.