Skip to content

feat(profiler): collapse the recursion of the call graph into a node per function, with UI 1.44 - #400

Merged
roxblnfk merged 3 commits into
masterfrom
feat/collapse-recursion
Nov 27, 2026
Merged

roxblnfk merged 3 commits into
masterfrom
feat/collapse-recursion

Conversation

@roxblnfk

@roxblnfk roxblnfk commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

🔍 What was changed

  • GET /api/profiler/{uuid}/call-graph takes recursion=collapsed: a node per function instead of a node per recursion level (foo, foo@1, … after XHProf). The response has recursion: levels|collapsed, so the UI knows the server takes the option; without the parameter the graph is as before.
  • The web UI is updated to buggregator/frontend 1.44.0, which has the «Collapse recursion» switch on the Call graph; docs/profiles.md describes it.
  • The Excimer sample of trap test has bar recursing over 20 elements, to show the recursion in the call graph.
  • The recursion-level summing of profile_calls moved to Struct\Recursion, shared with the call graph.

How it works

  • A merged node costs what its outermost calls cost, which take the deeper levels in; its count sums the calls of all levels for call profiles (bar (3x, 1 recursive), foo (2 sampled calls, 1 recursive) for SPX sampling), and takes the outermost level for sampled ones, where a sample counts once.
  • The calls between two merged nodes count each call's cost once, inside no other call of the same pair: exact along the recorded call tree (Xdebug, SPX, Speedscope, pprof, phpspy, collapsed stacks); by the recursion levels for a flat XHProf profile, an approximation that may leave out a recursion that came through another function. Direct recursion is a call from the node to itself, mutual recursion a cycle.
  • On the profiles of trap test: the 121-deep recursion goes from 128 nodes to 8, the Yii XHProf profile from 535 to 86.

Review notes

  • Default mode: byte-identical JSON to master apart from the recursion key, on random trees and every payload, with one exception: a call graph with a literal self-call (a==>a, which XHProf never writes, as it names the inner call a@1) now keeps a as a root, so a cycle below it gets linked to it.
  • The tree walk was checked against a brute-force count on 1 500+ random trees of call and sample profiles, hidden functions, recursive and multiple roots, numeric names: no difference.

Checklist

@codecov

codecov Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.50%. Comparing base (9044d76) to head (0742bc0).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #400      +/-   ##
==========================================
+ Coverage   82.40%   82.50%   +0.09%     
==========================================
  Files         489      490       +1     
  Lines       20739    20838      +99     
==========================================
+ Hits        17091    17192     +101     
+ Misses       3648     3646       -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@roxblnfk
roxblnfk force-pushed the feat/collapse-recursion branch from 284020f to d941dcc Compare November 26, 2026 18:07
@roxblnfk roxblnfk changed the title feat(profiler): collapse the recursion of the call graph into a node per function on request feat(profiler): collapse the recursion of the call graph into a node per function, with UI 1.44 Nov 27, 2026
…per function on request

A node per recursion level, as XHProf names them, turns deep recursion into a ladder of one function: `recursion=collapsed` merges the levels and draws direct recursion as a call of the node to itself. A merged node and its calls count each outermost call once: the calls along the recorded call tree, exact; along the recursion levels alone for a flat XHProf profile, where a call deeper in a recursion may have come through another function. The response tells the mode, so the UI knows the server takes the option. The MCP tools sum the levels the same way, now through one helper.

Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
The Call graph of a profile gets the «Collapse recursion» switch: a node per function, a function calling itself drawn with an edge to itself. The mock rule conditions of 1.44 need the mock server, which Trap has not.

Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
…se over 20 elements

The call graph then shows a recursion: a ladder of 20 `bar` levels, or one node calling itself with the recursion collapsed.

Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
@roxblnfk
roxblnfk force-pushed the feat/collapse-recursion branch from ac2789d to 0742bc0 Compare November 27, 2026 12:09
@roxblnfk
roxblnfk merged commit 0742bc0 into master Nov 27, 2026
29 checks passed
@roxblnfk
roxblnfk deleted the feat/collapse-recursion branch November 27, 2026 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request tests Changes in the tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Call graph: an option to collapse recursion into one node per function

1 participant