Repository navigation
perf(agents): share resident transcript strings across reloads - #185156
Merged
steipete merged 2 commits intoOct 26, 2026
Merged
Conversation
Contributor
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review in progressClawSweeper is reviewing this revision. This supersedes any previous blocked status. |
steipete
marked this pull request as ready for review
October 26, 2026 23:20
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. |
Reuse immutable resident strings while adopting fresh transcript containers. Keeps active history shared across orphan-repair and append reloads without changing transcript bytes, mutable-container isolation, ownership checks, or history windows.
steipete
force-pushed
the
steipete/perf-transcript-text-string-sharing-20261026
branch
from
October 26, 2026 23:33
97e1a7b to
1329469
Compare
steipete
deleted the
steipete/perf-transcript-text-string-sharing-20261026
branch
October 26, 2026 23:50
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Oct 27, 2026
…law#185156) * perf(agents): share resident transcript strings across reloads Reuse immutable resident strings while adopting fresh transcript containers. Keeps active history shared across orphan-repair and append reloads without changing transcript bytes, mutable-container isolation, ownership checks, or history windows. * fix(perf): preserve initial-context symbol type
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
Active runs retain duplicate copies of unchanged transcript text after SessionManager reloads, including reloads during orphan reconciliation and committed-append recovery.
User Impact
Lower retained transcript memory during active runs. Transcript content, persistence, history windows, mutable-container isolation, and reload/authorization checks are unchanged.
Why This Change Was Made
Initial model-context preparation already shares equal resident strings. Reload adoption now uses that same helper before publishing its fresh containers. Numeric and other non-string scalar leaves no longer allocate unused property descriptors. No cache or additional retained state is introduced.
Matching incoming values has a measured cost: approximately 0.064 ms more main-thread CPU and 138 KiB more sampled allocation per reload in this fixture. This is a retained-memory improvement, not an allocation-rate improvement. Runtime production code grows by 13 lines to share the existing implementation across both boundaries while preserving private mutable containers. The non-test diff is +226 lines including the 212-line reproducible benchmark and its one-line entrypoint registration.
Evidence
Acceptance: unchanged transcript/context digests, private mutable containers, changed persisted text remains authoritative, and fewer physical copies of unchanged large text across active history and SessionManager.
The regression exercises real SQLite hydration and reloads, verifies isolation and persisted rewrites, and checks physical string identity in a Node subprocess with independent positive/negative controls. The existing compiled-subprocess owner keeps preparation outside its 30-second deadline. The full hydration file passes 21 tests; the new regression takes 5.93 seconds. The exact same final regression fails on baseline with “reload copied resident transcript text”; it passes on the candidate. The V8 identity oracle was also checked on Node 24.22.1 and 26.12.1.
Owner workload: 69 entries, 57 active-history messages, 526,362 bytes of tool-result text, one initial context kept live across repeated bounded reloads. Timing and allocation run separately in AB/BA order: 2,000 measured reloads per arm per pair, two pairs (4,000 per revision per mode), after 20 warmups each. Measured base: a1b840f. Two-module source substitution pins the compared owner code; workers and remaining code are common.
Shared-host timing is context rather than a throughput claim. Timing host load (one-minute average, start→end): base 58.5→52.4 and 43.3→42.3; candidate 45.3→44.2 and 43.2→44.6. Maximum GC pauses per timing pair: 6.12→4.75 ms and 4.23→3.66 ms; major counts are below the percentile gate threshold. Allocation sampling includes collected objects and runs separately from timing.
The built-Gateway active-run capture starts each arm from the same preserved synthetic state. Four runs remain active with 12 large text references in their snapshot histories:
The snapshot Map shares runtime history in both arms; it is not another copy. Heap census groups use V8’s recorded 1,024-character prefix plus exact shallow size, so duplicate grouping is approximate; the regression independently verifies physical identity for exact values. This is a targeted retained-string reduction, not a whole-process heap claim: post-snapshot heapUsed was 534,780,808→563,623,944 bytes and RSS was 2,931,500,336→2,999,709,544 bytes. Other active-run allocations and capture timing vary. No overall memory-regression or throughput verdict is inferred from this single capture pair. A full Gateway throughput comparison is omitted: the Team-shaped stress harness rejected its startup shape census after maintenance changed archive counts. The isolated retention replay uses a 10,000-session synthetic fixture, 65 clients, four concurrent mock-provider runs with tool calls, and 40 plugins.
Focused validation: hydration (21 tests), initial-context/reload rejection consumers, prompt-prefix stability, both import-closure guards, and the export-name collision guard pass. Changed-file lint, formatting, and the core typecheck pass. The first CI run found unique-symbol type widening in the benchmark’s dynamic import; its declaration is corrected, and the exact failed script-types command passes locally. Runtime code and measurements are unchanged. Both sourcePerformance builds and the isolated active-run replays complete successfully. No Testbox lease or production Gateway was used.
Review: independent subagent review (autoreview route unavailable), no actionable P0–P2 findings. No provider configuration was changed.
Exact-head CI: run 40420528022 passed on
132946919da0c92fc67c84c4fb37effba1859ee4; the combined CI, dependency-review, and security-sensitive-review statuses are successful. Automated Codex review also completed on this head with no findings. This PR is ready and intentionally left unmerged for maintainer handoff.