Repository navigation
perf(cron): stream SQLite run history candidates - #174889
Conversation
Use one native SQLite cursor for cron history metadata while preserving bounded PostgreSQL batches, SQL payload projections, exact totals and page visibility. Baseline regression records two candidate reads for a 520-row history; the new boundary requires one. Codex autoreview found no actionable issues. Scale measurements and focused candidate proof are pending.
|
🦞👀 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 SummaryThis 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: stale review; fresh review needed. Summary Next step Review history (1 earlier review cycle)
|
Preserve the refactored cron history fixtures and carry the two single-SELECT assertions forward. The reviewed production worker is unchanged.
Read cron-history candidates through one native SQLite statement instead of 512-row cursor queries. Preserve metadata-only projections, exact totals, completion ordering, visibility and bounded PostgreSQL reads. Controlled RPC evidence: 43 to 2 statements at 20,000 runs and 394 to 2 at 200,000 runs, with two worker requests and zero MAIN statements unchanged. Row and payload volume remain unchanged; no latency saving is claimed. Three alternating shared-harness pairs retain identical causal warmed-turn counts. Focused cron/history and Gateway visibility tests pass.
What Problem This Solves
Cron history pages execute a new SQLite query for each 512 candidate rows. Stream those candidates through one native SQLite statement. PostgreSQL retains bounded keyset batches because its bridge buffers results.
The same owner preserves exact totals, completion order, filters, search and visible-session selection before hydrating the requested page. Large-payload JSON projections stay in SQL. No schema, public API or authorization changes.
Evidence
Each row covers both the first-in-workload and immediate-repeat calls. SQL counts are causal executed statements; rows are returned native rows, not visited rows or disk I/O.
Candidate SELECTs fall 40/391 → 1 at 1×/10×; selected-detail SELECTs remain one. Removing the separate SQLite snapshot accounts for two more statements. Exact totals and completion order still scan/sort all candidate metadata; this does not make a fifty-row page a fifty-row scan. Returned bytes remain approximately 6.5/65 MB per all-history call. The five-character-longer candidate fixture path explains the added candidate-row bytes; payload volume is not reduced. Loaded-host wall observations establish no latency improvement.
The SQLite keyset loop and separate snapshot wrapper are removed. Accepted edge: writes concurrent with the native SELECT remain outside that statement's snapshot. No authorization or stale-read check is removed; PostgreSQL retains its explicit snapshot across batches.
The 520-row regression fails on baseline (two candidate SELECTs) and passes with one. All 26 cron/history tests and 14 Gateway visibility tests passed, including freshness after recorded runs/delivery updates, timestamp ties, filtering, totals and bounded payloads. One isolated Codex review completed without actionable findings. Touched-owner T1 is 0 → 0. Required CI, types, typed lint, contracts/export collisions, Madge, ratchets and changed tests passed on integrated head
f5d18422a6e64e7405d9e8ea345f8e706157c391; final canonical Knip completed on the unchanged integrated head with eight production and six full-tree unused-export findings, all exact path/symbol matches to scheduled main run 39006528379, in files this PR does not touch. The scripts scan passed with zero entries. These inherited findings are disclosed and routed to the main-repair owner; no new finding was introduced. The frozen cumulative candidate previously passed all three scans with zero entries. SDK/update-cell checks do not apply. Scope: three files, +70/−49.The broader four-arm synthetic census records every RPC, including one candidate 10× usage-page assertion failure: the protocol returned an empty partial result. All four overview/page-two calls at that scale included partial metadata near the unchanged 15-second budget; the recorded metadata lacks the values needed to quote the wire reason. These are incomplete usage-view results, not savings. All 88 RPCs were observed in each arm; the other three arms passed 88/88 and candidate 10× passed 87/88. All observed RPC MAIN counts are zero, no observer-recorded native execution errors occurred, and all four Gateways exited cleanly. An earlier two-600k-session attempt failed with worker heap exhaustion; the final matched fixtures use two/twenty 60k-message sessions and prove population scaling, not 600k-session support.
Three alternating shared-harness pairs completed in M,C,M,C,M,C order on frozen baseline
a1bb732d30bc377dcc89f679822db7420d034357and cumulative candidate76b1ddeed66dd28e4708134290fb12ce073d30bc. Every arm passed fourteen turns, compaction, restart and clean shutdown, with zero observer-recorded native errors. Counts below are median [min–max].Causal warm count arrays match exactly. The +0.5 raw run-median SQL difference is background work, not an increase in the changed owners. Background MAIN reaches nine in a warm window; causal warm MAIN stays zero. Standard cron-history totals vary with one versus two
cron.runspolls: baseline 7 [4–7] SQL / 3 [2–3] requests, candidate 2 [2–3] / 2 [2–3]. No request saving is attributed to that variable polling. Small-fixture hydration remains 8 SQL / 2 requests in every arm. The controlled scaled RPCs above provide the owner-specific saving evidence.All six arms use the unchanged shared harness's supported zero-idle option, retaining normal settling, compaction and restart. Whole totals are descriptive, not default-idle or equal-call-count saving claims. No warmed-chat or latency improvement is claimed.