Repository navigation
perf(process): release contexts retained by long-lived error stacks - #185584
Merged
steipete merged 1 commit intoOct 27, 2026
Merged
Conversation
Contributor
|
🦞👀 Pull request received. I will update this pull request when review starts. |
Contributor
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. |
Contributor
|
steipete
deleted the
steipete/perf-long-lived-error-stack-retention-20261027
branch
October 27, 2026 07:00
This was referenced Oct 27, 2026
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Oct 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Problem This Solves
Long-lived process cleanup failures and revoked automation capabilities can keep expired execution contexts reachable through V8's unformatted Error stack frames.
User Impact
Releases those otherwise-unused contexts while preserving the original error object, error class, message, code/status, cause, and shutdown/abort behavior. No configuration or migration is required.
Why This Change Was Made
Materialize stacks at the supervisor cleanup-failure holders and cron capability abort boundary using the existing infrastructure helper. Keep formatting best-effort for immutable errors and opaque diagnostic getters so diagnostic work cannot replace a cleanup failure or prevent revocation. The prepared-model-runtime detached snapshot serves a different contract (dropping plugin prototypes and cause graphs) and remains unchanged.
This is a retained-memory tradeoff: eager formatting adds work on failure/revocation, with no change to the successful process or active-authority paths. Production runtime code grows by 13 net lines to cover the missing retention boundaries while preserving error identity; no cache, copied error representation, or competing owner is added.
Evidence
Node 26 owner harness, synthetic 10,000-session/40-plugin closure contexts; actual production owners with a synthetic child-process I/O adapter. Baseline:
2f81eacee9b2f91906265280897d4997960d440d. Five alternating base/candidate runs, 3,000 iterations per arm per run (15,000 per arm total); timing and sampled allocation run separately. Heap runs hold 16 independently-created contexts per arm and collect after stack frames unwind.CPU ranges were 38.43–52.17 → 55.48–82.06 µs (supervisor), and 5.47–7.42 → 21.29–27.12 µs (cron). Host one-minute load ranged 56–84 across arms. This does not establish a whole-Gateway CPU or latency gain: it exchanges about 16–24 µs and 4–6 KB per failure/revocation for releasing the expired contexts. The retained-byte result depends on the size of the caller's context. Uses the lane's cold-owner fast-path proof exception; no live server load test was run.
Reproduce with the usage in
scripts/perf/long-lived-error-stacks-measure.ts(--owner supervisor|cron,--mode timing|allocation|heap,--base-dirfor saved baseline owner sources). Formatting a small standalone held Error also changes a WeakRef payload from retained to collected.Two owner GC regressions exercise real lifecycle boundaries and preserve error identity/type/status; a formatter regression covers immutable/opaque diagnostics. Focused Node validation passes all 76 tests (supervisor 39, cron grants 28, error helper 9); test-file durations 3.41 s, 7.00 s, and 1.57 s respectively. Scoped oxfmt/oxlint, the export-name collision guard, and both import-closure files pass (29 closure tests, 245.89 s test duration). Independent subagent review (autoreview route unavailable) is scoped-clean at P2. The final two GC regressions and immutable-diagnostic regression all fail on the saved baseline source for the intended reasons and pass on the candidate. Exact-head CI is tracked in the PR workflow. PR CI owns broad validation.