Repository navigation
fix(workspaces): let checkpoints progress during manifest sweeps - #198157
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: needs maintainer review before merge. What this changesThis PR replaces the manifest sweep’s long SQLite read snapshot with reads bounded to 256 rows. Example: Workspace maintenance scans the reported 6.0 GB synthetic state database.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR is ready for landing consideration: no actionable findings remain, exact-head CI gates pass, and the owner explicitly accepted the measured performance tradeoff that blocked the previous review. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe workspace maintenance owner advances the sweep epoch, asks the existing read worker to discover unreachable manifest content, and sends candidates to the writer for epoch-checked deletion. flowchart TD
A[Workspace maintenance] --> B[Advance sweep epoch]
B --> C[Existing read worker]
C --> D[Bounded root and graph reads]
D --> E[Unreachable content candidates]
E --> F[Epoch checked writer deletion]
Technical reviewBest possible solution: Land the bounded reads in the existing sweep owner with its unchanged epoch safeguards and the explicitly accepted background performance cost. Do we have a high-confidence way to reproduce the issue? Current main visibly holds one read snapshot throughout discovery, and the supplied regression reports busy=1 on the exact parent versus busy=0 after the fix; this review executed no target code. Is this the best way to solve the issue? The patch is a focused repair: it removes the long snapshot, bounds existing scans by their primary keys, and preserves the existing publication and deletion owners without adding durable state. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 3370acfc7477. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +38, Tests +25, Docs +3, Other +48. Total +114 across 5 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. 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 HistoryReviewed November 13, 2026, 5:56 AM ET / 10:56 UTC (Revision 3). |
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. |
|
The completed 6.0 GB synthetic campaign is now in the PR body: median read hold 3,537.9 → 63.7 ms, with the measured total-time/CPU/read overhead retained and explicitly awaiting owner acceptance. All final-head CI checks passed in run 43389843075. Final head e552124 changes only a shadowed callback name after the reviewed implementation. There were no numbered open findings in the previous review. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Addressing the sole open review item on final head
Code and head are unchanged; the existing exact-head CI and independent Codex review still apply. @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…nclaw#198157) * fix(workspaces): release sweep reads between bounded pages * style(workspaces): avoid shadowing the sweep query helper
What Problem This Solves
Fixes: workspace maintenance pins a SQLite read transaction throughout a large manifest sweep, preventing checkpoints from completing between its graph reads.
User Impact
Maintenance releases each metadata read after at most 256 rows. Accepted trees, pending checkpoints and content reused or published during the sweep remain protected by the existing preparation epochs and deletion checks. No configuration, schema or retention-window change.
Why This Change Was Made
The existing projection is already narrow. Most IO comes from reaching child metadata and epochs stored after large pack payloads; selecting fewer columns cannot remove those overflow-page reads. This change removes the handler-wide read snapshot and pages roots and candidate scans using existing primary keys. Graph reads were already bounded. It relieves long checkpoint holds without claiming to eliminate the underlying multi-GB IO.
Production delta: +38 lines, needed for three bounded keyset scans; no cache, additional owner or durable cursor. The existing GC regression now checks an actual WAL checkpoint from another connection and concurrent publication/reuse. The old snapshot wrapper is removed.
Evidence
The regression fails on exact parent
1110e81c7b93da2eb1a8b3ba26f70cf4a9660553: the checkpoint reports busy=1. With the fix it reports busy=0 and all 12 CAS tests pass, including preservation of accepted, pending, newly published and reused content. Independent Codex review found no actionable P0–P2 findings. All 45 focused CAS/store/manifest tests and the full build pass.pnpm check:changedpassed its selected type, schema, database, format and boundary guards. Its new callback-shadow lint error is fixed and final focused lint passes. The remaining dead-export failure (sharedThemeProjection) also reproduces in both scans on the exact parent;18872ea508b988daae6e641e79b95ab10fe885ad/ #197549 removed its final consumer. This is a recorded main regression, not a new failure dismissed as noise. No UI-imported module is changed.Measurements and full build use
8f05cb9b9d733b202c5b60bb80c3a333592fc23c; the final source changes only a callback parameter name to satisfy lint, preserving SQL, types and control flow. That final delta has its own clean Codex review. Exact-head PR CI remains a landing gate.Acceptance rule, recorded before the paired campaign: warm production-handler sweep over a new synthetic ~6 GB state database, 10,000 projection rows and distinct 62,000-file manifests, stored at epoch 2 and swept at epoch 4. Two parent A/A controls, then five serial interleaved parent/candidate pairs each for timing, allocation and logical pager reads. Require identical candidate digests, at least 90% lower longest read hold, and no >20% adverse movement in paired wall/CPU/allocation medians; report p95, ranges and adverse cells. This is the existing state-owner workload, not a copied 35 GiB agent database or whole-Gateway transport test. Setup and warmup are excluded.
node --expose-gc --import ./scripts/tsx.mjs scripts/perf/local-workspace-manifest-read.ts \ 62000 1 timing /path/to/new-synthetic.sqlite --sweep --sweep-epoch=4 --target-bytes=6000000000 # Subsequent arms: --reuse --sweep --sweep-epoch=4; allocation uses the allocation mode.Prior retained evidence from #191779 attributes most native reads to child metadata after record payloads. Its synthetic covering child+epoch index experiment reduced logical pager bytes 3.808 GB → 0.155 GB, but the initial timing experiment was adverse and confounded. That is a proposal for separate schema-owner review, not justification to add an index here. No index experiment is repeated or shipped in this PR.
Completed sweep measurements
The fixture is 6,008,033,280 bytes: 234 accepted 62,000-file manifests, 145,548 packs and 10,000 projections. All 36 measured invocations returned the identical candidate digest and zero garbage, as expected for the all-live large fixture; the regression separately checks nonempty garbage and concurrent reuse/publication. Each mode has two parent A/A controls and five interleaved pairs. Values below are median / empirical p95 (maximum at n=5).
Read-hold median improves 98.2%; all statements return at most 256 rows. The tradeoff is explicit: timing median worsens 30.2%, p95 38.2%, CPU median 18.6%, allocation median 0.9%, logical reads 4.23%, and more statements replace the long scans. Owner-accepted tradeoff (November 13, 2026): Peter explicitly accepts this cost and directs landing. The production problem is a 28–32 second read-transaction hold on the shared state database on each maintenance pass, obstructing checkpoint progress. Reducing the fixture median hold from 3,537.9 ms to 63.7 ms is worth increasing total sweep time from 3,541.5 ms to 4,611.2 ms (+30.2%) and worker CPU from 3,163.6 ms to 3,750.8 ms (+18.6%), once per background pass. The remaining logical read volume is a separate follow-up; this acceptance does not claim lower IO or authorize a schema change.
Timing A/A wall was 3,071 / 3,044 ms and CPU 3,129 / 3,090 ms. All paired timing observations are retained: wall parent 3,119–5,834 ms, candidate 3,610–8,063 ms. The shared host was busy; the separate pager pass later measured wall medians 3,109 → 3,605 ms and CPU 3,169 → 3,663 ms. Those diagnostic runs do not replace the adverse untraced timing campaign. Native query execution dominates both separately captured CPU profiles; no compilation-cache fix or schema change is inferred.
Node 26.12.1 / SQLite 3.54.1 on macOS/APFS; logical pager counts use the retained native CACHE_MISS probe, 2 MiB cache and mmap disabled. Logical pager bytes are not physical disk bytes. This exercises the production read handler in-process, not Gateway scheduling, btrfs commits or chat latency. Real maintenance executes this operation in its existing read worker.