Repository navigation
perf(sandbox): reduce workspace reconcile payloads - #199524
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 sends incremental workspace pack records to the SQLite writer, which reconstructs complete packs, and adds bounded operation-level telemetry. Example: Reconcile one changed file in the reported 20,000-file workspace fixture.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-directed optimization addresses remaining reconciliation overhead and preserves the existing storage contract. No actionable correctness or security findings were identified; exact-head CI remains pending. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe workspace scanner compares live files with the accepted manifest, prepares immutable content, and sends it through the existing worker transport; SQLite stores complete packs before checkpoint acceptance publishes their root. flowchart LR
A[Workspace files] --> B[Manifest scanner]
B --> C[Changed records and predecessor references]
C --> D[SQLite worker transport]
D --> E[Existing writer transaction]
F[Persisted predecessor packs] --> E
E --> G[Complete immutable packs]
G --> H[Checkpoint acceptance]
Technical reviewBest possible solution: Carry incremental records through the existing preparation path and reconstruct complete packs in the existing SQLite writer. Do we have a high-confidence way to reproduce the issue? Current-main source confirms that a changed directory still serializes its complete sibling pack; the PR supplies a repeatable owner-boundary workload, which was inspected but not executed during this read-only review. Is this the best way to solve the issue? The change follows the existing ownership boundaries, preserves complete stored packs and deletion promotion, and removes duplicate caller-side pack selection; the added --reconcile-traffic switch is benchmark instrumentation only. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against f0e04c2f13af. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +108, Tests +29, Docs +4, Other +94. Total +235 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, 3:42 AM ET / 08:42 UTC. |
* perf(sandbox): send workspace reconcile pack deltas * perf(sandbox): include tree owner in wrapper extraction
What Problem This Solves
A small sandbox edit still retransmits an entire changed directory pack during reconciliation, adding allocation and pause time even after #199306 skips unchanged packs.
User Impact
Reconciliations send much smaller pack preparations. File contents, tree digests, conflict handling, acceptance, recovery, and persisted pack bytes stay unchanged. There is no schema, index, migration, configuration, or durability change.
Why This Change Was Made
The scan owner now carries predecessor pack references and changed treap records, including changed child references. The existing SQLite writer reconstructs the complete pack in its existing transaction. Initial publication and verified repair still supply full packs because no persisted predecessor is available. Missing predecessors use the existing baseline-repair error contract.
Payload telemetry now distinguishes 13 fixed
localWorkspace.*operation names inrequest_class; unknown suffixes retain the bounded family label. No workspace or path labels are introduced.Runtime production delta: +108 lines (+95 for delta preparation/reconstruction, +13 fixed metric labels). This growth preserves the current complete-pack storage contract instead of changing the schema. The scan caller loses its duplicate pack-selection logic. Benchmark instrumentation adds 91 net lines; the shared perf README is unchanged.
Evidence
Synthetic owner-boundary reproduction on baseline
c149398aacc4e9bb98e2398024b49a672668bdd4: 20,000 flat-directory files × 12,000 bytes (240 MB), 10,001 synthetic session rows, one changed file per reconcile, real filesystem/projection/SQLite owners. Only container pause/inspect I/O is simulated. This is not a built Gateway, native Podman/btrfs, or live-server result.Three pairs, 20 reconciles per arm per process (60 per revision), ordered ABBA then one predeclared BA pair for mixed timing signs. All arms are included. Work counts and payload bytes are deterministic; timings are noisy on the shared Mac.
Packing falls from 20,001 to 12 records. Both revisions perform 9 content hashes/reads, 108,000 bytes read, and 19,999 fingerprint hits per reconcile, including patch/capture/verification. The residual ~542 KB of mutation traffic is dominated by checkpoint/fingerprint publication; it is preserved. The complete directory pack is still written in SQLite.
The reported production-scale two-minute pause did not reproduce locally. Scanning/preparation dominates this fixture; filesystem/platform/host differences remain unqualified. Main CPU is approximately neutral. The mixed-sign timing arms below do not establish a consistent pause-speed guarantee.
Patch/application code is unchanged. Candidate arm 3 was slower across several unchanged phases at higher host load; no window was discarded. Per-phase wall times are context, while the complete reconcile and pause totals above include that arm. No adverse classification or rejection is based on these noisy subphase timings.
Every arm: CPU, allocation, pause, GC, event loop, memory, worker execution, and host load
Allocation uses the main-isolate V8 total allocation counter, including background work, excluding worker heaps and external buffers. Worker execution is
executeFinished - executeStartedfor all localWorkspace requests, rather than client round-trip time. RSS includes worker isolates. Loop delay includes synchronous fixture mutation subprocess startup and is not Gateway latency. Low-sample tails and major-GC counts are context; no GC/max-pause rejection was made.GC details by V8 kind (count / total ms / maximum ms):
The extended incremental-pack regression fails on baseline for edit and both deletion shapes: 15,026 / 9,234 / 14,909 bytes, against the 6,000-byte budget. The candidate passes while comparing
records_jsonandchildren_jsonbyte-for-byte with a full rebuild, retaining equal roots through acceptance and GC. Existing missing-pack recovery tests exposed an error-contract mismatch during development; preserving the established missing-baseline error fixed it.Validation: 46 focused CAS/scan/store tests and 5 SQLite client tests passed; the broader owner/projection run had 120 passing and 2 skipped tests, with two recovery failures then repaired and rerun successfully (2 passing). Closure guards, export-name collision check, changed-file lint/format,
pnpm tsgo:test:root, and matching gateway/infra test typechecks passed. Exact-head PR CI passed onaa7bb143a6c5c825c5643291312a295f987c1c73, including all PostgreSQL conformance shards and PostgreSQL 16 smoke. A 29-line allocation record covers the regression growth. The closure guard also found the newly eager tree module missing from the wrapper extraction inventory; the inventory was updated and both closure files now pass (24 tests).Reproduction (same committed harness for both frozen sources):
For subsequent arms use the same output with
--reuse-fixture --report <arm>.jsonand alternate--source-root. These reused, deterministic fixtures measure warm reconciliation; they do not qualify cold pack-insertion I/O. Keep the default TMPDIR. Source hashes, phase samples, request bytes, worker execution timings, hash/pack counts and memory are in each report.No Testbox or Team load was used. No 10-minute Gateway stress campaign was run. This reconciliation transport change has direct filesystem/worker proof; whole-Gateway behavior and native-container pause duration remain unqualified. Independent review is pending.