Skip to content

fix(inspector): count each recursive call once, not once per enclosing call - #960

Merged
lcottercertinia merged 1 commit into
certinia:mainfrom
lukecotter:bug-inspector-recursion-double-count
Aug 25, 2026
Merged

fix(inspector): count each recursive call once, not once per enclosing call#960
lcottercertinia merged 1 commit into
certinia:mainfrom
lukecotter:bug-inspector-recursion-double-count

Conversation

@lukecotter

Copy link
Copy Markdown
Collaborator

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

  • scopedCallTree drops 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.
  • EventVitals takes its Time total from sumDurationTotalForRootEvents, the helper the bottom-up grid uses for the same figure, so the two agree.
  • Each governor metric total now sums the outermost occurrences and each self reading every occurrence, through two named summers rather than one that switched on a string.
  • The former Avg row becomes Avg 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 test
  • New case in scopedCallTree.test.ts: an aggregate of nested occurrences totals the outer call alone, and counts both calls once.
  • New case in EventVitals.test.ts: a self-calling method totals the outermost call and averages the self time of every call.
  • Manual, Analysis tab on a log with a recursive method: the row's Calls and the inspector's Bottom Up Calls agree.

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
lcottercertinia merged commit 753b7fb into certinia:main Aug 25, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants