Repository navigation
perf(infra): release caller graphs from retained error stacks - #186147
Conversation
Materialize retained error graphs at failure owners while preserving error identity and classification. Extend the shared helper to aggregate siblings and expose it through the error-runtime SDK surface. Three real-owner retention regressions release 24 MiB of caller buffers and about 5 MiB of session objects per three stored failures. Eager stack formatting adds 11–16 microseconds per recorded failure in synthetic owner measurements. Census and measured tradeoffs live beside the benchmark script.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
|
Codex review: needs maintainer review before merge. What this changesThis PR formats retained error stacks across existing runtime and plugin owners so completed callers can be collected. Example: Three failed SQLite opens each capture an 8 MiB caller buffer.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it addresses retained caller memory that current main still permits, with no discrete introduced bug found; exact-head CI failures remain unattributed. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherRuntime and plugin failure owners receive errors from completed operations and retain them for later rejection, retry, or cleanup; the shared helper materializes their nested stacks before storage. flowchart LR
A[Caller operation] --> B[Failure]
B --> C[Existing failure owner]
C --> D[Shared stack materializer]
D --> E[Retained original error]
E --> F[Retry or cleanup consumer]
Technical reviewBest possible solution: Keep the existing failure owners and shared materializer, preserving original errors while releasing their captured caller graphs. Do we have a high-confidence way to reproduce the issue? Current-main source retains unformatted errors and misses aggregate siblings; the supplied baseline/candidate owner measurements demonstrate the retention mechanism, but were not rerun during this read-only review. Is this the best way to solve the issue? The change uses the existing shared helper and retention owners, preserves classification and settlement policy, and introduces no competing cache or lifecycle owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 7fa041d80fc2. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +195, Tests -1, Docs +108, Other +110. Total +412 across 68 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 27, 2026, 1:31 PM ET / 17:31 UTC. |
|
Admin-merging over |
…aw#186147) * perf(infra): release caller graphs from retained error stacks Materialize retained error graphs at failure owners while preserving error identity and classification. Extend the shared helper to aggregate siblings and expose it through the error-runtime SDK surface. Three real-owner retention regressions release 24 MiB of caller buffers and about 5 MiB of session objects per three stored failures. Eager stack formatting adds 11–16 microseconds per recorded failure in synthetic owner measurements. Census and measured tradeoffs live beside the benchmark script. * fix(ui): resolve the shared error graph source subpath
What Problem This Solves
Fixes request buffers and session graphs staying alive after failures are cached or retained by long-lived runtime and plugin owners.
Related: #185584, #185647, #186100.
User Impact
Failed database opens, catalog requests, plugin shutdowns, transports, and worker lifecycles release otherwise unreachable caller data while keeping the original error identity, messages, codes, causes, and retry/authority behavior. No configuration or schema changes.
Eager stack formatting costs additional CPU and allocation when a failure is recorded. In the measured fixtures this adds about 11–16 µs per operation and releases roughly 29 MiB per three retained failures. This is a retained-memory fix, not a throughput improvement.
Why This Change Was Made
V8's lazy Error stacks can retain captured frames after the throwing operation ends. Materialize them at the existing failure owner rather than layering another cache or replacing Error instances with lossy records. The shared helper now traverses nested aggregates as well as causes and is available through the existing
error-runtimeSDK entrypoint.The per-script census records fixed stores, existing protections, short-lived/string-only cases, and explicit follow-ups. Production delta: +195 lines across 61 files; identity/classification and retained-error contracts require keeping the original objects, so each existing storage boundary needs a small materialization call. No new runtime state or compatibility path.
Evidence
Acceptance: a retained real owner must release every caller fixture while preserving error identity/classification and failure policy. Three synthetic owners each retain three failures created with 10,000 sessions, 40 plugin descriptors, and an 8 MiB buffer per caller. Baseline
b4b328b903ecec99179255bbe6f6c95fac885f45: each retains 3/3; candidate: each retains 0/3. SQLite includes anAggregateError.errorschild without a cause link.Five counterbalanced pairs, 3,000 operations per side; untraced timing and separate sampled-allocation passes:
Post-GC heap delta per three records: SQLite 5,236,888 → 18,512 B; catalog 5,226,616 → -6,336 B; Matrix 5,231,808 → -744 B. Small negative deltas are GC noise. Host load ranged 41.08–45.70.
Commands:
node --expose-gc --import ./scripts/tsx.mjs scripts/perf/long-lived-error-stacks-measure.ts --owner <sqlite-latch|catalog-backoff|matrix-stop> --mode <heap|timing|allocation>; heap regression uses--records 3 --assert-collected, costs use--iterations 3000, baseline uses--base-dir <pinned-source>.No production service was touched. No whole-Gateway load test or throughput/GC/latency claim: this follows the scoped fast path for terminal error storage rather than a hot successful request path. No remote validation lease allocated; PR CI supplies broad proof.
Independent subagent review (autoreview route unavailable): initial patch and lint follow-up clean at P0/P1/P2. The configured Codex autoreview preflight refused the requested route because it did not match operator configuration; no configuration was changed.
Focused SQLite latch (2 tests), catalog backoff (4), error-graph, bounded queue, async-work-scope, binary-stream, MCP transport/client (32), and auth-storage (41) checks passed. A first MCP setup attempt was invalidated by source edits during compilation; rerun on frozen source passed. Catalog wrapper took 197 s including 133 s of worker preparation; its retention test took 4.84 s. SQLite wrapper took 2.74 s. Full focused rerun took about 8 minutes, dominated by compiled-worker preparation and existing auth tests. Export collision guard passed. The required eager-import and PR-wrapper closure guards passed (32 tests), and the final error-graph rerun passed (12 tests). The test-line ceiling is unchanged; net test-line delta is -1 (the inherited tree remains 315 lines over its ceiling).
Changed-file formatting and lint passed. Rebased onto current main without conflicts; the patch is unchanged. Exact-head CI completed with the attributed exceptions below.
CI on the first head exposed a missing Control UI Vite subpath alias after the shared error graph gained a runtime import. Added the specific
normalization-core/error-coercionsource alias before the broad root alias. The existing Vite configuration file passes all 39 tests; changed-file lint/format and independent review passed. The UI build/E2E and Node shard failures from that head are attributable and addressed in4a9cea446b4beb9639ae997ff49f500332d21152; the production UI build and UI performance job pass on the new head.Final exact-head CI and failure attribution
CI run 40548562227 completed on
4a9cea446b4beb9639ae997ff49f500332d21152. CI remains red; this is not a green-check claim. Six test jobs failed, plus the aggregate gate. Build artifacts, core/extension lint, test types, package boundaries, docs, baseline ratchets, QA smoke, Docker seed E2E, UI performance, and PostgreSQL conformance passed. No failed CI jobs were rerun.extensions/x/src/events.test.ts, unparseable-streak case24e16034180f7a08eda5f17d2a2b573cde1868a5: 1 failed / 18 passed on both. Focused wrapper times 4.57 / 3.43 s. CI job.src/config/sessions/session-accessor.sqlite-archive-session.test.ts, idle retirement with open scope falseui/src/e2e/chat-startup-priority.e2e.test.ts:235, hidden suggestion refreshui/src/e2e/chat-header-subagents.e2e.test.ts:211ui/src/e2e/chat-cold-load-anchor.e2e.test.ts:404sessions.messages.unsubscribetimes out in focused headless browser runs on head and unchanged parent: 1 failed / 2 passed on both (36.82 / 30.44 s test durations). CI job.ui/src/pages/chat/chat-view.test.ts, two decorative-prefix casesBaseline checks used the same lane checkout, temporarily detached at the unchanged parent and returned to the PR branch afterward. Only the named failing files ran locally. The working tree is clean. This PR remains open and unmerged for the maintainer handoff; no merge or CI rerun was requested.