Skip to content

feat(diagnostics): name what grew in renderer OOM crash reports - #9984

Merged
brennanb2025 merged 12 commits into
mainfrom
brennanb2025/renderer-heap-highwater
Jul 23, 2026
Merged

brennanb2025 merged 12 commits into
mainfrom
brennanb2025/renderer-heap-highwater

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

What & why

Renderer OOM is now Orca's dominant crash class: the July crash-channel sweep shows ~38 of ~40 recent macOS crashed (exit 5) reports — and 34 Windows oom reports — with the V8 heap pinned at the ~3.5 GB ceiling (usedHeapMB=2661…3586 / heapLimitMB=3586, trajectories like 25→2823→3586 over hours). But renderer_memory breadcrumbs record only heap totals, so every report says that the heap grew and nothing about what grew.

This PR makes the next OOM self-diagnosing:

  • renderer_memory_highwater breadcrumb, emitted once per threshold per session when the heap crosses 60% / 80% of the limit, carrying leak-diagnosis counts: DOM node census, terminal element count, heap totals, and per-subsystem counts.
  • Contributor registry (renderer-memory-profile.ts): subsystems push counters in, so crash-diagnostics stays a leaf module. Counts only — never raw buffers — with a 32-count per-contributor cap and a 64-count aggregate cap.
  • The store registers the first contributor: its 20 largest top-level collections by size, so a leaking slice (worktrees, agent statuses, terminal maps…) is named in the report.

Fix evidence

This is instrumentation, so the evidence is behavior proofs (unit-tested) + bounded cost (adversarially verified):

  • One-shot & ordering: tests drive the 60s sampler through 6% → 70% → 85% and assert exactly one 60 emission, no re-emission on repeat ticks, then one 80 emission; a fresh session at 85% emits both levels in one tick. A NaN heap reading emits nothing (and cannot disarm the one-shot).
  • Runaway contributors: one contributor returning 500 keys lands exactly 32 in the payload; aggregate collection stops after 64 output counts or 64 contributor calls, so empty contributors cannot create unbounded near-OOM fanout.
  • Zero steady-state cost (verified in review): below threshold the 60s path adds two number comparisons and a division — no allocation, no DOM access, no contributor calls. The DOM census runs at most twice per session.
  • End-to-end boundedness (verified in review): breadcrumb stores cap at 30 entries, values at 240 chars, final report at 64 KB — the ~26-key payload fits every layer.
  • Tests: 17/17 across both renderer diagnostics files plus 6/6 breadcrumb-store tests; full typecheck and production Electron/Vite build clean; diff-scoped oxlint/oxfmt clean.\n- Base typecheck repair: the fresh lockfile exposed two current-main uses of ReturnType<typeof stat> resolving to an optional overload; both now use Node’s concrete Stats type.

ELI5

Today's crash reports are like a bathroom scale that only says "you gained weight" — every OOM report shows the memory number maxed out, with no clue which part of the app ate it. This change adds a tripwire: the first time memory passes 60% (and again at 80%), the app writes down a quick inventory — "how many worktrees, how many terminal elements, how big is each data table" — into the crash report. When the crash lands in the crash channel, the report itself names the suspect instead of needing a week of archaeology.

Trade-offs

  • No user-facing behavior change. Nothing renders differently; healthy sessions do zero extra work (two comparisons per minute).
  • The DOM census (O(nodes)) runs at most twice per session, on a renderer already near OOM — a few ms worst-case, in exchange for the key diagnostic.
  • Crash-report breadcrumbs grow by ~26 numeric keys, within all existing retention caps.
  • This PR diagnoses the OOM cluster; it does not fix the leak itself. It's the standard step when a leak class isn't locally reproducible: instrument, ship, read the next report.

Adversarial review & perf

  • Adversarial loop: 2 rounds → CLEAN (fresh sub-agent each round).
    • Round 1: essentially clean; 1 minor logic flaw found and fixed (NaN heap reading would have spuriously emitted both levels and permanently disarmed the one-shot — guard now uses a finiteness type predicate), plus the defensive 32-key cap and jump-to-80% coverage it suggested.
    • Round 2: verified all three fixes empirically (3 flake-free runs), traced the one-shot/dispose semantics, payload caps, and registry lifecycle — CLEAN.
  • Perf review: initial review confirmed the threshold-gated, counts-only shape; follow-up audit found that empty contributors bypassed the aggregate count budget. Fixed by capping both output counts and contributor calls at 64, with a 100-contributor regression test.

Follow-ups (not this PR)

  • Register a terminal-subsystem contributor (scrollback totals) once a cheap counter seam exists.

Renderer OOMs are the dominant crash class (heap pinned at the ~3.5GB V8
ceiling in crash-channel reports) but renderer_memory breadcrumbs carry only
heap totals, so reports say "it grew" without saying what.

Add a one-shot renderer_memory_highwater breadcrumb at 60%/80% of the heap
limit carrying leak-diagnosis counts: DOM node census, terminal element
count, and per-subsystem counts from a new contributor registry. The store
registers the first contributor, reporting its 20 largest top-level
collections. Counts only, capped per contributor; zero work on the 60s
sample path while below threshold.
@coderabbitai

coderabbitai Bot commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds bounded renderer memory profiling, including contributor registration, state collection summaries, finite-value filtering, error handling, and budget limits. Renderer diagnostics now emit one-time memory high-water breadcrumbs with surface and profile data, while the crash breadcrumb store retains threshold profiles separately from recent breadcrumbs. Pop-out and store integrations identify the renderer surface and contribute state metrics. Tests cover these behaviors, a lifecycle assertion becomes order-independent, and skill release metadata and snapshot registry JSON are updated.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is detailed, but it does not follow the required template sections like Summary, Screenshots, Testing, Security Audit, or Notes. Reformat the PR description to match the template and add the missing required sections, including screenshots/no visual change, testing checklist, security audit, and notes.
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the renderer OOM breadcrumb diagnostics change.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@brennanb2025
brennanb2025 merged commit eb2508e into main Jul 23, 2026
1 check passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…lyai#9984)

* feat(diagnostics): name what grew in renderer OOM crash reports

Renderer OOMs are the dominant crash class (heap pinned at the ~3.5GB V8
ceiling in crash-channel reports) but renderer_memory breadcrumbs carry only
heap totals, so reports say "it grew" without saying what.

Add a one-shot renderer_memory_highwater breadcrumb at 60%/80% of the heap
limit carrying leak-diagnosis counts: DOM node census, terminal element
count, and per-subsystem counts from a new contributor registry. The store
registers the first contributor, reporting its 20 largest top-level
collections. Counts only, capped per contributor; zero work on the 60s
sample path while below threshold.

* fix(diagnostics): retain renderer heap profiles

* test(agent-status): remove subagent row order race

* fix(diagnostics): bound aggregate heap profile work

* fix(diagnostics): bound heap profile contributor calls

* fix(types): avoid overloaded stat return inference

* fix(diagnostics): fully bound heap profile registry

* chore(skills): refresh release snapshot manifest

* fix(diagnostics): retain browser counts in heap profiles
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.

1 participant