Repository navigation
perf(sqlite): reuse admission snapshots across worker requests - #168647
Conversation
Prepare immutable admission publications at the registry owner instead of rebuilding every fact map and cursor fingerprint per RPC. Preserve shared revocation and generation-aware retirement across workers. No schema or persistent-state changes.
|
🦞👀 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 prepares SQLite admission snapshots at publication and reuses them across unchanged worker requests. Example: Reported Linux benchmark with 513 admissions and real task-pool RPCs.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it addresses admission-transfer overhead still present on main, and no actionable introduced defect was found. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe process-wide SQLite admission owner receives validated facts and writer registrations and transfers snapshots to workers whose consumers check shared validity cells. flowchart TD
A[Database admission] --> B[Admission registry]
B --> C[Published snapshots]
C --> D[Task and broker RPCs]
D --> E[Worker installation]
E --> F[Fact consumers]
G[Shared validity cells] --> F
Technical reviewBest possible solution: Land publication-owned snapshot reuse through the existing admission owner once required CI is resolved or independently qualified for the native inherited-failure exception. Do we have a high-confidence way to reproduce the issue? Current-main source shows admission-wide reconstruction during unchanged RPC dispatch, supported by the reported comparable boundary measurements; this review executed no target code. Is this the best way to solve the issue? Moving reconstruction to publication removes the repeated cost at its existing owner while preserving shared invalidation and generation checks. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against de691c1ec3c0. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +40, Tests +85, Docs +6. Total +131 across 6 files. Added test files: 0. View PR surface stats
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 HistoryReviewed October 10, 2026, 5:36 PM ET / 21:36 UTC (Revision 3). |
|
The three failing CI jobs are inherited from the CI merge’s
All three report the duplicate The exact PR head is |
…law#168647) Prepare immutable admission publications at the registry owner instead of rebuilding every fact map and cursor fingerprint per RPC. Preserve shared revocation and generation-aware retirement across workers. No schema or persistent-state changes.
What Problem This Solves
Worker RPC dispatch scanned every retained SQLite admission, copied each fact map, checked shared validity cells, and built string fingerprints before discovering that nothing had changed. Unchanged reply installation also rebuilt the environment snapshot. This makes ordinary Gateway requests more expensive as more physical databases and writer registrations are admitted.
User Impact
Admission transfer now has constant work between publications, reducing main-thread CPU in long-lived Gateways. First-use validation, shared revocation, writer custody, host-only completeness, and generation-aware retirement remain enforced. No schema, stored-data, permission, configuration, or upgrade/downgrade changes.
Why This Change Was Made
The admission registry prepares snapshots at publication and transfers only changed records. Requests compare one registry revision; weak cursors do not retain old snapshots. Installation of unchanged facts is a no-op. Shared cells invalidate transferred facts immediately. Publication and explicit full captures reclaim remotely retired records, without deleting a newly admitted generation of the same file.
The old capture/fingerprint implementation is removed. Transfer and installation now share one owner in the existing admission-record module; native identity/lifetime handling stays in the admission module, which shrinks by 39 lines. Total production delta is +40 lines (139 added, 99 deleted), excluding tests/support/docs: immutable publications, weak cursor retention, and generation-safe cleanup replace per-call reconstruction. The existing line-growth gate required moving the cohesive registry logic out of the already oversized native module.
Evidence
Same-host before/after on a Linux rig, Node 26, synthetic databases, real task-pool and SQLite broker RPCs. Each cell measures 2,000 calls after 100 warmups;
process.threadCpuUsage()measures the host thread.At 513 records, task CPU improves 13.0× and broker CPU 5.1×. Another 20,000 task RPCs retain exactly 513 admissions in both versions; median CPU per 1,000 calls falls from 400.86 ms to 29.66 ms. Records follow admitted physical databases, not call count. This is worker-boundary and call-count soak evidence, not an end-to-end Gateway load test or a multi-hour production deployment.
The snapshot-reuse regression fails on the original code and passes after the change. It covers stable publications, unchanged installation, changed-record transfer, shared revocation, and retirement. The existing worker regression now also retires and re-admits the same physical file and checks sibling admission IDs agree.
Validation:
3050cdc493af8832fe2092045402d35e5fb1fda5and final candidate confirms 17 identical inherited findings, zero new findings (auth modules, UI test support, and Solid lint tooling).pnpm test src/infra/sqlite-schema-facts.native.test.ts --maxWorkers=1— 54 passed, 42.92 s Vitest / 47.08 s command wall time on the rig. No new test file, shard, or worker boot was added. The existing file owns the added case.451903329fee2aa605ee05fa4dc07c1e6f7decc0; all six changed files are byte-identical to the reviewed/tested candidate. Exact-head CI follows on2238957b8d553630c2b1a3bc7536cb42f4461bf5.Earlier remote runs: Blacksmith Testbox
tbx_01m4kmm5bxwak90a7d7nef1g6nran the focused tests and original-code regression plus before/after benchmark successfully (62 passed, 3 skipped; 26.60 s Vitest / 28.41 s wrapper), following an initial regression failure corrected in the same scope. Its later gate never started because checkout sync timed out. AWScbx_3462d14149c9and Hetznercbx_3396f1b4d4f6fallback commands also remained in checkout transfer and were stopped before test execution. All leases were stopped; the final proof used the approved rig fallback.CI on the exact PR head completed with three inherited failures:
check-additional-boundaries,check-lint-core-2, andcheck-test-types-core-1. Each reports the duplicate helper import at lines 8 and 10 inui/src/e2e/mobile-sidebar-session-menu.e2e.test.ts. That file has the identical blob in the CI main parentad2d6022a02d4d087c71cf5dd818f5802ff351b4and tested merge1500bdc37d3c40e02e4dbcfbb35018c0ae46c4f4; the error reproduces with the one-file boundary lint on that unchanged parent. All other selected CI jobs passed or were intentionally skipped. The native pre-existing-failure verifier accepted the pinned run, parentage, source identity, scoped tests, and current writer authority. No CI rerun was requested.