Skip to content

perf(viewer): stream bounded flamegraph previews - #849

Open
rcoh wants to merge 1 commit into
codex/flamegraph-node-budgetfrom
codex/flamegraph-progress-events
Open

rcoh wants to merge 1 commit into
codex/flamegraph-node-budgetfrom
codex/flamegraph-progress-events

Conversation

@rcoh

@rcoh rcoh commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Keep lightweight kind: "coverage" SSE events for every refinement update.
  • Add bounded kind: "partial" flamegraph trees at exponentially spaced file-coverage checkpoints.
  • Seed one cached file before returning to the normal 24-file batch size, improving time to first render.
  • Limit partial trees to 16 frames and 2,000 nodes; keep the terminal kind: "final" projection at 50,000 nodes.
  • Preserve the active canvas view as later partial trees replace earlier ones.
  • Leave legacy response formats and the generic fold driver behavior unchanged.

Why

The previous revision avoided the original 600 MB response by sending coverage-only events and building the tree once. That removed the payload explosion, but it also meant the UI had no renderable data until the expensive final projection completed, so users saw only a spinner while files folded.

Rebuilding the full exact tree after every file would restore the old CPU/allocation problem. Bounded, depth-limited previews provide useful incremental results without repeatedly constructing or serializing the final 50,000-node projection.

Protocol

flat-v1 now streams:

  1. coverage after each merge that does not cross a preview checkpoint.
  2. partial after file coverage crosses 1, 2, 4, 8, 16, ... files.
  3. One final event after the work list drains.

The first cached seed batch contains one file so an existing folded set can produce a preview before the remaining cached files are merged in normal bounded batches.

Dependency

Depends on #848.

Stack

  1. perf(viewer): intern aggregate flamegraph frames #846 Frame interning
  2. perf(viewer): flatten aggregate flamegraph trees #847 Flat parent-indexed tree rows
  3. perf(viewer): bound flamegraph projections #848 Deterministic node budget
  4. perf(viewer): stream bounded flamegraph previews #849 Bounded incremental previews (this PR)
  5. perf(viewer): merge flamegraph parts without state clones #850 Transactional in-place part merges

Validation

Validated on the complete stack:

  • cargo fmt --all -- --check
  • cargo clippy -p dial9-viewer --all-targets --all-features -- -D warnings
  • cargo nextest run -p dial9-viewer (530 passed)
  • cargo nextest run -p dial9-viewer --stress-duration 20s (one full iteration, 530 passed)
  • Flamegraph-focused Vitest suites (91 passed), UI typecheck, and Vite production build
  • 480,000-sample simulator request: 877 KB total SSE payload; 25-node/depth-16 partials and a 50,000-node/depth-38 final tree
  • Playwright screenshots at 1,900 x 1,000 verified both the in-flight partial tree and settled final tree

@rcoh
rcoh force-pushed the codex/flamegraph-progress-events branch from 32870cb to 9362099 Compare August 28, 2026 15:27
@rcoh rcoh changed the title perf(viewer): stream flamegraph coverage before final tree perf(viewer): stream bounded flamegraph previews Aug 28, 2026
@rcoh
rcoh force-pushed the codex/flamegraph-progress-events branch from 9362099 to 0c13510 Compare September 1, 2026 20:45
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