Repository navigation
perf(boards): reduce read latency under host load - #166403
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. Reviewed October 6, 2026, 11:44 PM ET / October 7, 2026, 03:44 UTC (Revision 2). ClawSweeper reviewWhat this changesBoard snapshots and widget documents use the retained session-history reader to reduce database handshakes, with updated boundary tests, architecture documentation, and a test-only typing repair. Warning SQLite table change This PR modifies persisted SQLite tables in Merge readiness✅ Ready for maintainer review The optimization remains useful on current main, and no blocking patch defect was found. The earlier migration-proof concern does not apply: the patch preserves the stored format and existing read kernels. Priority: P2 Review scores
Verification
How this fits togetherBoards stores session widgets in per-agent SQLite databases. Gateway requests read snapshots and documents through the Board store, then apply current authorization before returning data or issuing view tickets. flowchart TD
A[Gateway Board request] --> B[Capture session and database]
B --> C[Shared writer FIFO]
C --> D[Retained read worker]
D --> E[Coherent SQLite snapshot]
E --> F[Identity and authority checks]
F --> G[Snapshot or widget document]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +8, Tests +123, Docs +2. Total +133 across 10 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Retain one read-worker owner for durable Board reads while preserving existing kernels, FIFO consumption, and live disclosure checks. Do we have a high-confidence way to reproduce the issue? Not applicable as a correctness-bug reproduction; the supplied real-handler benchmark establishes a concrete latency scenario, and current-main source confirms the extra publication handshakes. Is this the best way to solve the issue? Yes. Reusing the existing read owner and kernels removes the measured overhead without adding a competing cache or changing persistent data. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 30d563e262aa. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
Serve durable Board snapshots and widget documents through the retained session history reader. Preserve writer FIFO consumption, live authority, physical identity, and close revocation while removing the write-capable read publication and redundant snapshot copy.
Use an inline module type query in the exact-allowlist pass-through mock. The type-only namespace triggered seven false full-tree Knip findings for live fallback exports. The same failure reproduced on the unchanged parent; the corrected test, export scans, and changed checks pass.
f1087c7 to
bb5e0f3
Compare
* perf(boards): reduce read latency under host load Serve durable Board snapshots and widget documents through the retained session history reader. Preserve writer FIFO consumption, live authority, physical identity, and close revocation while removing the write-capable read publication and redundant snapshot copy. * test(models): avoid false unused auth runtime exports Use an inline module type query in the exact-allowlist pass-through mock. The type-only namespace triggered seven false full-tree Knip findings for live fallback exports. The same failure reproduced on the unchanged parent; the corrected test, export scans, and changed checks pass.
What Problem This Solves
board.getopens a write-capable SQLite publication for every durable snapshot, including empty boards. Repeated host/worker handshakes amplify event-loop delays. Widget-document reads pay the same cost.User Impact
Faster Board reads under host load, with unchanged response shapes and per-principal authorization. No schema, stored-data, configuration, or update migration is required.
Why This Change Was Made
Move the existing read kernels into the retained session-history read worker and delete the writer backend's read mode. Preserve writer FIFO consumption, logical and physical identity checks, native mutation fencing, and live Gateway authority before disclosure. Retain canonical and requested paths so closing either revokes an alias-backed reader. External consumer promises release the FIFO before settling; incognito keeps its existing owner.
The reader owns connection admission and retirement. Each operation reads a fresh coherent SQLite snapshot; no result cache is added. Freshly decoded snapshots no longer receive another deep copy.
A small test-only CI repair replaces a type namespace with an equivalent inline module type query in the existing exact-allowlist mock. The original syntax caused seven false Knip findings for live auth-profile exports. All production exports and scanner rules remain intact.
Evidence
Real
board.gethandler, identical synthetic SQLite fixtures, Linux x64 / Node 26.8.1, 100 warm calls per row. Four widgets contain 127,004 stored HTML bytes; responses contain metadata only. Pressure adds 10 ms of synchronous host work between worker replies.The pressured empty read went from about eight host-work turns per request to fewer than one on average. Ordinary cold reads were 1,489 → 668 ms empty and 1,222 → 593 ms populated. The rig was shared: ordinary empty-board p99 worsened, and pressured candidate maxima reached about 200 ms. The timed fixture starts at the handler; network and Gateway request admission are outside these numbers. Production latency still needs deployment measurement.
Validation: 77 tests across eight Board/Gateway/history-reader files passed on the authorized Linux rig fallback (401.22 s wall);
pnpm buildpassed (7m 37.6s). Blacksmith Testboxtbx_01m4a42mhardevcc2hy4rmrbdn, profileopenclaw-check, passed the 25-test Board worker file (46.84 s wrapper wall / 29.11 s Vitest; 74.458 s remote command including verification). Final-head Testboxtbx_01m4a7m2jdg99q27caxj1xg28apassed all 19 Gateway boundary/ownership/shutdown cases (90.63 s wrapper wall / 88.13 s Vitest; 114.582 s remote command). These replace the earlier rig Gateway runs as the final Gateway proof. The two exact-allowlist cases passed (14.27 s wrapper wall). Independent P0–P2 reviews passed for both the implementation and CI repair.The full changed gate passed production checks and all 27 test typecheck projects, then exposed the inherited Knip failure. The exact seven findings reproduced on the unchanged parent. After the typing repair, staged checks, all three Knip scans, original Board lint, and every remaining schema/storage/import/webhook/pairing guard passed on the same Testbox. No skip flags or baseline exceptions were used. Both new regressions have negative controls: the original writer-publication read fails its guard; omitting alias registration permits disclosure after canonical close, while the corrected reader rejects it.
Production LOC: +8 net (+127 / -119). Board-specific runtime shrinks by 69 lines; two typed request/reply operations with captured database identity and their admitted dispatch add 77 lines to the existing reader. That transport contract accounts for the growth. The old read publication, execution capture/cleanup, and redundant copy are removed completely.
Commands and provenance
Testbox verified the source SHA and changed-file bytes before execution. The initial two leases queued; the first disappeared and the second was stopped before a head change. The third lease above ran the Board/check proof, and the fourth ran the final-head Gateway proof. Both were stopped after proof.
The remaining original gate commands ran directly: changed-file oxlint, native state schema version, database-first legacy stores, media download helpers, runtime sidecar loaders, import cycles, webhook body order, pairing-store grouping, and pairing account scope. All passed.
Rig focused command:
Measurements and rig proof used base
4e9a106d1a2. Testbox checked the rebased source and the staged CI repair. Both final commits preserve the reviewed patch IDs. Earlier rig changed-check runs were stopped when superseded; they are not claimed as passing gates. Final-head CI run 37567730575 passed onbb5e0f3f68c59abe5994e5878a7ba128055080f8; CodeQL, critical quality, OpenGrep, and security review also passed. All Testbox leases are stopped/gone, and both task-owned rig worktrees are removed.