Repository navigation
perf(sessions): avoid serializing retained tool classifications - #183548
Merged
steipete merged 3 commits intoOct 25, 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. |
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. |
steipete
force-pushed
the
steipete/perf-mailbox-match-stable-stringify-20261025
branch
from
October 25, 2026 11:29
48b3558 to
f029328
Compare
steipete
force-pushed
the
steipete/perf-mailbox-match-stable-stringify-20261025
branch
from
October 25, 2026 11:40
f029328 to
d28099a
Compare
steipete
deleted the
steipete/perf-mailbox-match-stable-stringify-20261025
branch
October 25, 2026 11:56
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Oct 26, 2026
…claw#183548) * perf(sessions): avoid serializing retained tool classifications * test(sessions): use stored actors in classification fixtures * test(perf): type the bounded classification fixture lookup
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
Every retained session-entry publication serialized two temporary classification objects per retained tool-authority reader, even when only unrelated metadata changed. This created avoidable allocation during active turns.
User Impact
Reduces publication CPU and allocation without changing tool-authority classification, sandbox policy, or revocation behavior. No new configuration, retained cache, schema, or public API.
Why This Change Was Made
The existing classification predicate owns five facts: session ID, lifecycle revision, sandbox requirement, sandbox mode, and creator actor. Compare the scalar fields directly and compare admitted actor data structurally with prototype checks skipped. Key order remains irrelevant. Missing versus explicit
undefinedactor properties remain distinct; missing versusundefinedtop-level optional classification fields remain equivalent, as they were in the previous projection. Live caller authority and retained predicate lifecycle are unchanged.Runtime production LOC: 8 added / 9 removed (net −1); benchmark +218 lines; tests exercise the retained publication contract. Deleted the classification projection and both serialization calls; no cache or alternate path. The separate lifecycle target collector is outside this change.
Evidence
Acceptance declared before measurements: identical publication outcomes, at least 10% owner allocation or CPU reduction, no material regression under absolute GC/tail thresholds, and net nonpositive production LOC. Five alternating, counterbalanced pairs per instrumentation mode, serial on macOS with Node 26.12.1. Workload: 48 synthetic active sessions, four retained classification readers/session, 10,000 warmup publications then 200,000 measured metadata publications/run (800,000 comparisons). All 192 retained readers remain current after every run. Neither side performs resets; this owner workload does not model reset boundaries.
Timings/GC are untraced. Allocation uses a separate in-process sampling heap profile at 32 KiB with collected objects included. Promotion uses a separate V8 trace pass with its own baseline. No forced collection in measured windows; no pause trimming or post-hoc exclusions. No A/A rejection controls were needed: total GC, promotion, mean latency and CPU all improved. Minor pause changes below 1 ms are context.
All untraced collections were minor; major/incremental/weak counts were zero on both sides, so major-GC behavior is unmeasured. Minor p95/p99 and candidate loop p99 are context where counts fall below 200/1,000. Both GC maxima are reported per pair above; none approaches the 50 ms safeguard. Sampled allocation beneath
stringifyStableValuefell from approximately 8.76 GB/run to zero. All runs use identical work counts; wall-time tails remain noisy on the shared host.Reproduce with
node --import ./scripts/tsx.mjs scripts/perf/reply-classification-publication-measure.ts --output result.json; the script header documents separate allocation and promotion modes. Compare this script against the base and candidate source with five alternating pairs each.Validation: baseline publication-equivalence suite passed (17 tests); after correcting the stored-actor fixture, all 17 cases also passed against the original comparator (37.40 s including preparation). Final candidate:
node scripts/run-vitest.mjs src/auto-reply/reply/reply-tool-authority.snapshot.test.ts src/auto-reply/reply/reply-tool-authority.worker.test.ts --maxWorkers=1passed 28 tests, 83.35 s total including compiler preparation; worker file duration 18.50 s. Changed-file oxfmt, oxlint (source and benchmark configs), andgit diff --checkpassed. The export-name collision guard passed;test/scripts/eager-import-closure.test.tsandtest/scripts/pr-wrapper-source-closure.test.tspassed all 22 tests (41.30 s including preparation). Initial declaration preparation caught the legacy boolean comparison option; fixed to the typed options object and repeated all measurements. Broad typechecking is deferred to PR CI under local compute limits.Review: independent subagent review (autoreview route unavailable), scoped clean at P0–P2. The helper refused the requested route because it did not match the operator configuration; no configuration changed. Reviewed the frozen diff plus owner, actor-schema, and serializer context. Author simplification pass removed temporary projection/serialization machinery without adding cache state. This behavior-preserving refactor intentionally keeps equality tests green on the baseline; the owner allocation measurement exposes the old performance defect.
Limits: owner-level synthetic publication proof, not a full streaming Gateway/WebSocket benchmark or production speedup claim. No major collections occurred. Broad validation belongs to PR CI. After deployment, inspect collected-object allocation below retained classification
matchesduring entry publication: its stable-stringify stack should disappear while session-policy changes continue to invalidate retained authority.Leave ready for maintainer review; do not merge as part of this lane.
CI correction: the first
check-test-types-core-2run caught my fixtures using the projected actor'sidentityfield instead of storedsource/delegatedBy, plus an invalid Vitestit.eachgeneric. Corrected both and passed the exact affected messaging test-type lane (node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.messaging.json --incremental). Independent follow-up review of the corrected fixture and actual stored-actor type is clean. The corrected snapshot file passed all 17 tests (55.18 s including preparation); the unchanged worker suite had passed all 11 tests. The runtime comparator is unchanged.All performance tables above were remeasured from scratch with valid stored actors after that correction. Earlier malformed-fixture results are superseded, not selectively trimmed: allocation 47,539→3,477 B/publication; six-pair CPU 15.857→4.158 µs/publication; loop p99 4.872→2.787 ms, including one adverse pair at 3.111→5.497 ms. The replacement five-pair workload has improving loop p99 in every pair, so no mixed-sign extra pair was needed.
Minor GC p95/p99 ms by pair (baseline → candidate; counts above):
Allocation and promotion spread (five separate pairs; 200,000 publications/side/pair):
The next CI run passed 58 checks, including all core test-type shards, production types, Node/UI tests, and guards; its remaining failure was script
noUncheckedIndexedAccesson the benchmark's fixed-array modulo lookup. Added the erased non-null assertion after independent review of the bounded index. Lint/format pass; runtime code and benchmark work are unchanged by the erased type annotation, so the measurement tables remain applicable. No CI reruns were requested merely to chase green.Final CI: run 40189869394 completed successfully for exact head
d28099a37730020170c7860f72c94866876bab06. GitHub code review also completed on that head with no findings. This PR is intentionally left ready and unmerged for the lead.