Skip to content

perf(sessions): reuse exact actor admission entries - #184071

Merged
steipete merged 2 commits into
mainfrom
steipete/perf-actor-admission-entry-payload-20261026
Oct 26, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/perf-actor-admission-entry-payload-20261026

Conversation

@steipete

@steipete steipete commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Warm session actor commands resend the complete session entry at transaction and commit admission even when main already retains that exact immutable entry. A synthetic 32 KiB skills snapshot dominates those messages.

User Impact

Less worker-message allocation during session activity, with no user-visible behavior change, schema migration, or new configuration. Cold commands and commands whose entries change keep their complete policy payloads.

Why This Change Was Made

The command borrows the replica preimage already retained for settlement. Its write token is a compression hint: the worker must match that token against its authoritative preimage, and may reference it only while entry object identity remains unchanged. Main resolves the reference only within that command. Target validation, live authority checks before and after policy callbacks, final grants, FIFO ordering, and rollback/unknown settlement remain intact. This also preserves accepted commands whose snapshot disclosure has been revoked.

Version fields alone are insufficient: they still describe the old revision during intermediate mutations. Changed entries therefore travel in full, rather than introducing a delta protocol or another cache. This is the residual after #184018, whose authority projection is already in the measured baseline.

Runtime production delta: +36 LOC (48 additions, 12 deletions). Exact-revision matching, fail-closed reference resolution, and complete changed-entry fallback account for the growth. Benchmark tooling adds 58 net lines; the requested non-test/non-doc diff including tooling is +94 LOC (143 additions, 49 deletions). No shared performance README edit.

Evidence

The real actor/native-admission regression fails on baseline 18d2633de8abd677ae1852b48950701bce8ff302: 33,276 snapshot bytes, exceeding the <1,024-byte budget. With the candidate, both transaction and commit admissions of the warmed tool append satisfy that budget (2/2 references), while the complete entry remains available to policy. This is a targeted warm-flow result, not a production-wide hit-rate estimate.

66 focused tests pass: actor integration (28), worker and replica (38). Coverage includes stale reference fallback, changed-entry commit rejection/rollback, stale actor versions, live authority revocation, native settlement recovery, and accepted work after disclosure revocation. Actor file wall time 50.41 s; worker/replica invocation 61.69 s, dominated by worker compilation. Changed-file lint/format, git diff --check, and core/scripts typechecks pass. A callback parameter type error found by typecheck was corrected; an earlier compiled-subprocess setup failure ran no tests and is not counted as product evidence. The first CI run caught a numeric birthtime in the synthetic benchmark fixture; it now matches the string identity contract. The scripts type lane passes locally, and all measurement pairs were repeated on that corrected fixture (the table below uses only the complete fresh run). Production code was unchanged by that correction. PR CI supplies broad validation; no Testbox lease was used.

Independent subagent review (autoreview route unavailable): fresh-context Codex review found no actionable P0–P2 findings. The helper refused the requested provider because it did not match operator configuration; configuration was not changed. The reviewed change rebased cleanly; the intervening replica change only factors an unrelated transcript reader.

Owner measurement

Acceptance declared before measurement: equivalent reconstruction, lower bytes, consistent CPU/allocation improvement. Native MessageChannel sends, a synthetic 32 KiB skills prompt, 1,000 warmups, five alternating AB/BA pairs of 5,000 admissions per arm per mode (25,000 per arm per mode). Timing is untraced; allocation is a separate collected-object sampling pass.

Mean per 5,000 admissions Baseline Candidate Absolute / relative delta
Thread CPU 36.598 ms 13.076 ms −23.522 ms / −64.27%
Sampled allocation 173,205,989 B 7,627,982 B −165,578,006 B / −95.60%
Serialized bytes per admission 33,236 B 325 B −32,911 B / −99.02%

Every pair improved: CPU reductions 53.36–71.61%, allocation reductions 95.51–95.71%. One-minute host load was 41.51–46.46. These numbers cover matched-entry owner transport, not total Gateway CPU or all admissions. The benchmark uses a short synthetic token; the production-path test above checks real token size.

Reproduce using scripts/perf/session-actor-admission-measure.ts --synthetic --mode timing (via node --import ./scripts/tsx.mjs), repeat with --mode allocation; --owner <baseline-command.ts> selects the baseline projection. Existing synthetic Gateway state mode is preserved.

The lane's fast-path exception applies: this removes duplicate serialization without changing policy decisions, so no multi-pair ten-minute Gateway stress campaign was run. Whole-Gateway event-loop/list latency, server handler latency, allocation rate and steady-state RSS/heap are unmeasured. The short owner harness observed zero GC samples, so it supports no GC conclusion. No live Team load was started.

@clawsweeper

clawsweeper Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-26T01:59:41.667992Z ffda894 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation scripts Repository scripts size: M labels Oct 26, 2026
@steipete
steipete force-pushed the steipete/perf-actor-admission-entry-payload-20261026 branch from f9e8c84 to ffda894 Compare October 26, 2026 01:57
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 26, 2026
@clawsweeper

clawsweeper Bot commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR replaces repeated unchanged session-entry admission payloads with references to the command’s retained preimage.

Example: A warm tool-result append with a 32 KiB skills snapshot.

  • Before: Both admission boundaries resend the complete entry; the reported baseline snapshot is 33,276 bytes.
  • After: Both admission snapshots stay below 1,024 bytes while policy receives the complete retained entry.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch is focused and source-consistent; supplied proof establishes owner-level savings and harness behavior, with no shipped-entry-point demonstration.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; supplied actor/native-admission regressions and transport measurements support the narrowly stated optimization.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Session activity repeatedly allocates and transfers large saved entry snapshots that main already retains.
Reason: The maintainer-authored direction has measurable owner-level value, limited runtime growth, and no new public option or persistence contract.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it provides a measured, focused optimization that current main lacks, with no actionable correctness or security findings.

Priority: P2
Reviewed head: ffda894aebf5fd1ae9fc04054c037d6911eda3c1

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The supplied evidence does not exercise a shipped Gateway turn; its scope is native admission harnesses and MessageChannel measurements.
Agent review details

How this fits together

Session actors execute mutations in the existing database writer; admission facts travel to the main thread for live policy checks before native commit and receipt settlement.

flowchart LR
  A[Session command] --> B[Main thread replica]
  B --> C[Database writer actor]
  C --> D[Entry or exact reference]
  D --> E[Live admission policy]
  E --> F[Native commit and settlement]
Loading

Technical review

Best possible solution:

Retain this command-local compression path with full changed-entry fallback and the existing live admission owner.

Do we have a high-confidence way to reproduce the issue?

Current-main source unconditionally serializes complete entries at admission, and the PR supplies a baseline byte-budget failure; no target code was executed during this review.

Is this the best way to solve the issue?

The change reuses the settlement preimage and existing projection owner, preserves complete policy facts, and avoids a second cache or delta protocol.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against b9fecb8982aa.

Provenance checked

  • Admission projection keeps the original intent (1dee1c2: Remove unused replica metadata while retaining complete entry facts required by live policy.)
  • Immutable replica borrowing keeps the original intent (230ea68: Share frozen internal revisions and require explicit copies for mutable consumers.)
  • Transaction and final admission boundaries keeps the original intent (c400e2a: Coalesce redundant tool-result admissions while retaining current authority, FIFO, rollback, and native settlement.)
  • Deferred receipt publication keeps the original intent (37a9f05: Prepare receipts and final admission through the existing transaction or certified single-node write path.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 5bd4f88 adds src/config/sessions/session-actor-sqlite.ts:131 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 5bd4f88535c6; files: src/config/sessions/session-actor-sqlite.ts)

PR surface

Source +36, Tests +26, Docs +6, Other +58. Total +126 across 12 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 6 48 12 +36
Tests 4 39 13 +26
Docs 1 6 0 +6
Config 0 0 0 0
Generated 0 0 0 0
Other 1 95 37 +58
Total 12 188 62 +126

Review metrics

Metric Value Why it matters
Production versus test growth Runtime +36 LOC; tests/support +26 LOC; benchmark tooling +58 LOC. Runtime growth supplies exact-reference matching and resolution through existing owners; tests cover payload cost, fallback, and rollback.

Labels

Label changes:

  • add P2: This is a bounded session-performance improvement with measured transport savings and no demonstrated urgent user-facing failure.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: This is a bounded session-performance improvement with measured transport savings and no demonstrated urgent user-facing failure.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 25, 2026, 10:12 PM ET / October 26, 2026, 02:12 UTC.

@steipete
steipete merged commit 6f8748a into main Oct 26, 2026
140 of 141 checks passed
@steipete
steipete deleted the steipete/perf-actor-admission-entry-payload-20261026 branch October 26, 2026 02:26
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 26, 2026
* perf(sessions): reuse exact actor admission entries

* test(sessions): match admission benchmark identity types
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant