Repository navigation
perf(sandbox): reuse saved workspace fingerprints during acceptance - #199683
Conversation
|
🦞👀 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 Summary: ✅ CompletedThis 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 reuses checkpoint fingerprints during workspace acceptance instead of sending the same inventory to the database worker again. Example: Accept a one-file edit in the reported 30,000-path SQLite workload.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR removes measurable duplicate workspace transport work through the existing persistence owner, with no introduced correctness or security defect found; exact-head CI remains pending. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherSandbox reconciliation saves a recovery checkpoint, applies workspace changes, and accepts the resulting baseline through the shared-state writer; commit receipts then update the Gateway's retained projection. flowchart LR
A[Workspace scan] --> B[Durable checkpoint reservation]
B --> C[Workspace reconciliation]
C --> D[Acceptance reference]
D --> E[Revision and root checks]
E --> F[SQLite fingerprint publication]
F --> G[Gateway commit receipt]
Technical reviewBest possible solution: Retain the existing checkpoint and writer owners, reuse their saved fingerprints, and preserve exact durable and host publication equivalence. Do we have a high-confidence way to reproduce the issue? Pinned main visibly resends saved fingerprint inventories, and the PR reports a red-on-base real-writer byte regression; no target code was executed during this read-only review. Is this the best way to solve the issue? The change follows the smallest complete approach: remove duplicate transport, resolve the existing durable fact under revision and root checks, and reuse the decoded local publication patch without adding a cache or persistence owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 89ee0bd382d1. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +60, Tests +22, Docs +6, Other +120. Total +208 across 10 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes:
Label justifications:
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 November 15, 2026, 11:59 AM ET / 16:59 UTC. |
What Problem This Solves
Sandbox workspace acceptance resends the full fingerprint inventory after the same bytes have already been saved in its recovery checkpoint, even for a one-file edit.
User Impact
Large local workspaces send substantially smaller acceptance requests to the database worker. File contents, accepted roots, conflict and rejection behavior, rollback journals, and persistence timing remain unchanged. No schema change or migration is required.
Why This Change Was Made
Acceptance now references the checkpoint held by the writer under the existing row revision. The writer verifies its roots and publishes its saved fingerprints. Main retains the local publication facts and decodes fingerprint buffers once for commit receipt and acknowledgement, removing the repeated decode.
Legacy checkpoints without saved fingerprints retain their existing conversion path. The production diff is +60 net lines: the additional code separates wire references from local publication facts and resolves the durable reference, including rejected-checkpoint envelopes. This trades repeated main-thread serialization for one worker-side checkpoint read/parse. There is no new cache or stored format.
Evidence
A synthetic filesystem reconciliation with 30,000 files (246 MB) and 10,001 session rows reduced acceptance requests from approximately 406,780 bytes to 770 bytes (99.8%). All eight one-file edits published the expected canonical contents. Other mutation fields were small: journal request approximately 1.3 KB, pause/resume and cleanup 414–514 bytes, and prepare approximately 2 KB. The initial reservation still persists approximately 408 KB of newly captured checkpoint data; that durability write is unchanged.
The byte census attributes the duplicate to
mutation.manifest.fingerprints, not authority predicates, rows, unchanged manifests, or journals. This fixture did not reproduce a 19 MB individual mutation. Its checkpoint fingerprint field was approximately 406 KB, while its delta manifests were hundreds of bytes.Owner benchmark: two counterbalanced pairs, 1,024 cycles per arm per pair (2,048 per revision), 30,000 paths, real SQLite writer. Each cycle performs admission, checkpoint reservation, acceptance and cleanup, then verifies durable readback. Timing and byte census use separate processes.
CPU and small heap-allocation differences are inconclusive, not claimed speedups. Four matched identical-code control pairs varied by up to 19.6% in whole-cycle main CPU, 16.4% in process CPU, and 35.3% in acceptance CPU. An earlier candidate round had opposite timing results (+19.6% main CPU, +25.3% process CPU), while the final round was −14.0% and −10.2%. Final arms' host 1-minute load changed 42.1→37.5 / 35.9→32.9 / 31.5→22.3 / 21.7→20.4 (ABBA). The deterministic win is removing duplicate serialized bytes; V8 heap accounting excludes those external buffer allocations.
The filesystem burst (8 edits per side) observed main CPU 434.6→384.8 ms, process CPU 9,070.5→8,134.1 ms, allocation 21.46→23.19 MB/edit, elapsed 8.46→8.37 s, loop p99 21.54→17.04 ms (675 samples each; context only), and GC 55.95→39.97 ms/min (one major collection each; context only). Host load was 24.9→23.4 vs 21.4→23.0. Each side recorded one minor, one major and one incremental GC: minor total/max 1.09→1.16 ms, major total/max 5.95→4.01 ms, incremental total/max 0.85→0.41 ms. These short samples do not establish a latency or GC improvement.
sessions.listlatency is not measured by this owner workload.Unforced main memory after the sustained owner burst, averaged across two arms (MiB):
The old-space gap after the burst is essentially unchanged (11.84→12.05 MiB); no retained-memory or RSS improvement is claimed. Natural worker retirement and GC make RSS deltas unsuitable as a win here.
Formatting, file-scoped lint,
pnpm tsgo:test:root, and the gateway core-test typecheck pass. The scripts report field-level bytes, per-operation CPU/allocation and unforced memory so this comparison can be repeated. Runtime production delta is +60 lines; non-test/non-doc delta including benchmark instrumentation and its allocation record is +180 lines.Regression: the existing real-writer root-publication test now retains fingerprint blobs and verifies durable fingerprint equivalence, a request smaller than 2 KB, and refusal of a mismatched checkpoint reference. It fails on the baseline at 22,621 bytes > 2,048 bytes and passes with the change.
Focused proof: 125 passed, 2 environment-dependent skips across
local-workspace-store.test.ts,local-workspace-cas.test.ts,local-workspace-projection.test.ts, andsrc/agents/sandbox/local-workspace.test.ts. This includes rejected-checkpoint recovery, conflicts, rollback, archive/restore, and lost-reply settlement. The skipped cases require native Podman or filesystem support for non-UTF8 filenames.The filesystem run exercises the real preparation/reconciliation/publication and SQLite owners with synthetic state; only container engine I/O is mocked. It is not a native Podman, model, WebSocket, or ten-minute Gateway load result. Owner-level CPU, allocation and memory measurements use fresh processes and fixed-work cycles; RSS and unforced heap snapshots are context, not evidence of a retained-memory reduction. Independent review is pending.
Exact-head hosted CI run passed on
103b181bfdab1751a2842bc8ecbfb035dc6b8477. All selected test, typecheck, lint, and baseline jobs passed without reruns. Independent review remains pending.