Skip to content

perf(cron): stream SQLite run history candidates - #174889

Merged
steipete merged 2 commits into
mainfrom
dbasync/uirpc-cron-stream
Oct 17, 2026
Merged

steipete merged 2 commits into
mainfrom
dbasync/uirpc-cron-stream

Conversation

@steipete

@steipete steipete commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

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.

RPC Scale SQL before → after Worker requests MAIN Returned rows before/after
All history 1× / 20k runs 43 → 2 2 → 2 0 → 0 20,050
Page two 1× / 20k runs 43 → 2 2 → 2 0 → 0 20,050
One job 1× 4 → 2 2 → 2 0 → 0 150
All history 10× / 200k runs 394 → 2 2 → 2 0 → 0 200,050
Page two 10× / 200k runs 394 → 2 2 → 2 0 → 0 200,050
One job 10× 4 → 2 2 → 2 0 → 0 150

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 a1bb732d30bc377dcc89f679822db7420d034357 and cumulative candidate 76b1ddeed66dd28e4708134290fb12ce073d30bc. Every arm passed fourteen turns, compaction, restart and clean shutdown, with zero observer-recorded native errors. Counts below are median [min–max].

Shared-harness observation Baseline SQL / requests / MAIN Candidate SQL / requests / MAIN
Warm raw, 30 pooled turns 67 [67–87] / 22 [22–27] / 0 [0–9] 67 [67–87] / 22 [22–27] / 0 [0–9]
Warm causal, 30 pooled turns 67 [67–68] / 22 [22–23] / 0 [0–0] 67 [67–68] / 22 [22–23] / 0 [0–0]
Raw warm run medians 67 [67–67.5] / 22 [22–22] / 0 [0–0] 67.5 [67–67.5] / 22 [22–22] / 0 [0–0]
Whole workload, idle observation omitted 3687 [3673–3688] / 952 [949–959] / 201 [200–201] 3681 [3641–3690] / 946 [940–965] / 201 [199–201]

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.runs polls: 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.

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.
@clawsweeper

clawsweeper Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-17T05:08:24.948494Z f5d1842 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: S labels Oct 17, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 17, 2026
@clawsweeper

clawsweeper Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: stale review; fresh review needed.

Summary
The latest durable ClawSweeper review was for head 1eec59564f6ff3e1266487e918022571fc4a2a67, but the PR head is now f5d18422a6e64e7405d9e8ea345f8e706157c391. Its old verdict and PR readiness labels are no longer current.

Next step
Run or wait for a fresh ClawSweeper review on the current PR head.

Review history (1 earlier review cycle)
  • reviewed 2026-10-17T00:50:20.819Z sha 1eec595 :: needs changes before merge. :: none

Preserve the refactored cron history fixtures and carry the two single-SELECT assertions forward. The reviewed production worker is unchanged.
@clawsweeper clawsweeper Bot removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 17, 2026
@steipete
steipete merged commit f211df0 into main Oct 17, 2026
132 checks passed
@steipete
steipete deleted the dbasync/uirpc-cron-stream branch October 17, 2026 07:43
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 18, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant