Repository navigation
perf(update): skip empty reconciliation snapshots - #193359
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 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: needs maintainer review before merge. What this changesThis PR skips reconciliation read transactions when no running update matches, while preserving snapshots for nonempty results. Example: Reconciliation excludes the ledger’s only running update.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it is a focused, maintainer-backed optimization absent from current main, with no introduced correctness or security defect found. Priority: P3 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherGateway and updater reconciliation send selection criteria to the shared-state reader, which returns update records and recovery facts for the existing writer to revalidate before mutation. flowchart TD
A[Gateway or updater] --> B[Shared state reader]
B --> C[Reconciliation selection]
C --> D[Empty result]
C --> E[Nonempty snapshot read]
E --> F[Writer revalidation]
Technical reviewBest possible solution: Retain this small reader-owned optimization and complete the existing validation gates before landing. Do we have a high-confidence way to reproduce the issue? The parent dispatcher unconditionally opens a snapshot before discovering an empty reconciliation result; source inspection establishes the overhead, and the body reports matching parent/head measurements without this review executing target code. Is this the best way to solve the issue? The patch uses the existing reader and transaction helper, preserves writer revalidation, and adds no cache, state, public API, or competing owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d0eb40dc0153. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +14, Tests 0. Total +14 across 3 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. Review metrics
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
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 Reviewed November 5, 2026, 4:46 AM ET / 09:46 UTC. |
Let the reconciliation owner skip read transactions for empty selections while retaining the existing composite snapshot for nonempty runs and already-pinned callers. The synthetic boot/restart workload removes eight statements with unchanged warm turns. Related: openclaw#190918, openclaw#191332.
What Problem This Solves
Update reconciliation starts a read transaction even when no running update matches the request. Startup and restart pay BEGIN/COMMIT for an empty result.
Why This Change Was Made
Related: #190918, #191332.
The reconciliation reader first uses its existing row selection without opening a transaction. An empty result needs no accompanying recovery or restart-sentinel facts. A nonempty result is discarded and selected again inside the existing snapshot before inspecting those facts. Already-pinned callers keep their snapshot. Other admission commands retain their transaction.
No schema, cache, generation, recovery decision, write admission, or SQL projection changes. This accepts one extra SELECT on the uncommon nonempty unpinned path to remove empty-path transaction work. An empty read performs no mutation; its discovery cutoff remains the SELECT. An idle empty watcher has no periodic timer: later discovery comes from admission or a scheduled wake, an explicit status read, or restart.
Evidence
Acceptance before candidate measurement: frozen v3.1.5 synthetic Gateway/WebSocket workload on the exact parent and candidate, including boot, 14 turns, history/control RPCs, nested turn, cron, connected idle, and restart. Count SQL statements, worker requests, and Gateway MAIN by operation; cold/restart and warm remain separate. Expected: eight fewer BEGIN/COMMIT statements in updateRuns.reconciliationCandidates, no request increase or MAIN increase. All shared session-read families and causal first/warm turns must hold. Any new adverse cell of 20% stops acceptance; the explicitly accepted nonempty-path SELECT is recorded separately. This is count evidence, with no latency or CPU improvement claim.
Initial current-main reproduction on 97b24c9: reconciliation 12 SQL / 4 requests / 0 MAIN. The synthetic workload has no update_runs table, so this reproduces missing-table empty envelope overhead, not an existing-table empty SELECT. An existing real-ledger regression separately verifies the empty-result contract after excluding the only running update.
Regression: the existing-ledger empty selection returns the correct result on the parent but issues BEGIN/COMMIT (two exec calls); with the change it returns the same result with zero transaction commands. All 52 focused reader, worker-reconciliation, and recovery-admission tests pass (89.26 seconds for the three-file run). Two isolated Codex P0–P2 reviews are scoped-clean. PostgreSQL semantic review approved this exact head. All three PostgreSQL shards, required normal PR CI, and both published-driver update steps passed on the exact head.
Exact-parent refresh:
bc11de935b017b79c2c5cd407c750d8cc1cdebc4, after config-health landed. The frozen baseline passed before the production cut: 2967 SQL / 796 requests / 105 MAIN overall; reconciliation remains 12 / 4 / 0. Ten warm turns have median 49 / 14 / 0, p95 52 / 15 / 0, ranges 49–52 / 14–15 / 0. The earlier reproduction is context, not the new exact-parent comparison.Simplification: transaction ownership moves into the existing reconciliation reader; the shared dispatcher no longer unconditionally pins this command. Production is +14 lines; tests are net zero by reusing the existing equivalent state-database fixture teardown. No new exported API.
Open-PR overlap: all ten indexed peer heads were unchanged at refresh. Paired
git merge-treecomparisons add no conflict paths or blocks: #163964 (581→581 paths), #162160 (580→580), #162144 (579→579), #162132 (579→579), #162126 (579→579), #161344 (583→583), #152205 (610→610), #151441 (584→584), #150246 (582→582), #148581 (582→582).Final frozen pair on the exact parent above and
81182484b0d91dbb4119918c64b4b84d8b3ef1b4:Ten warm turns per arm in one same-platform pair; warm ranges are 49–52 SQL, 14–15 requests and zero MAIN in both. All count-conservation checks pass, unknown attribution stays 9 SQL / 25 requests, and exact-entry, actor hydration, row facts, entry receipts, snapshot reads and rewrite watermarks are unchanged. Both workloads complete boot, real WebSocket turns, five-minute connected idle, restart and clean shutdown. No timing or CPU saving claim.
Whole-workload SQL rises by 23 despite the targeted eight-statement saving. Operation attribution shows +30 SQL / +1 request from unchanged transcript-index
installStatusTrackingon the restart turn, +1 SQL each from unchanged deletion snapshot, model catalog and unattributed-to-request worker bookkeeping, and -2 SQL from memory-source reads. The restart turn's 141→174 SQL (>20%) is disclosed as unchanged-owner initialization, not accepted as a reconciliation regression or a whole-workload improvement. Runtime MAIN stays zero; total MAIN stays 105. Phase-placement changes in unrelated background requests are not causal warm-turn changes.Local
check:changedpasses format, typed lint, all selected type lanes, source contracts, T1/dialect guards and Madge (zero cycles). Its script Knip scan is clean; production/full Knip fail only on the pre-existinghandleUpgradeRequestexport insrc/secrets/egress-proxy/proxy-forward.ts. That file is byte-identical on parent and candidate; current main already fixes the export in73145ebb3d2af927adab8aff1ed6040d30b2b5d8. This is not reported as a clean local aggregate. CI static results and merge-tree inclusion of that fix are verified separately before landing.Supplemental run 42001310015 dependency job 127157750439 reports only that same export. Scheduled main run 41994726590 at
ba75cf710e1589b58af0b547de2df9e17468e2fb, job 127135524057, independently reports it at the identical source blob. Current main's repair is already included in the clean prospective merge tree. No static exception for a PR-caused failure is used. The hosted review completed on the exact head with no findings.Supplemental-only UI observation: run 42001310015, job 127157747987, passes 32 cases and fails
ui/src/e2e/slack-inline-identity.e2e.test.ts:144because the transcript remains a loading skeleton instead of containing the expected text. That UI source is untouched. This is recorded as an unverified out-of-scope observation, not a matching-main reproduction or a passing check. The required normal PR run is tracked separately.Exact-head normal CI 42001291157 completed successfully, including PostgreSQL jobs 127157761487, 127157761457 and 127157761367 and required gate 127169429907. No source push or CI retry was needed.
Published-driver update: run 42001310015, job 127165041922 passed both “Update published driver to candidate” and “Update published baseline under native systemd” using the candidate package from this exact-head run. The supplemental run is not claimed green: its inherited dependency-export failure and separate unverified UI observation are recorded above. The required normal PR run is green. No source changes or test retries followed review.