Repository navigation
perf(db): remove redundant consume and deletion probes - #183069
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. What this changesThis PR adds an acceptance plan for removing redundant queries from pairing redemption, capture deletion, and progress retention. Example: Redeem an initialized pairing join code once.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Partial Merge readiness✅ Ready for maintainer review Keep this maintainer-authored draft open: it registers a focused performance experiment but does not yet implement the SQL reductions. No actionable defect was found in the documentation patch. Priority: P3 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherGateway operations reach existing database owners that consume pairing codes, delete capture records and payloads, and retain bounded outbound progress history. flowchart TD
A[Gateway operations] --> B[Pairing worker]
A --> C[Capture kernel]
A --> D[Progress store]
B --> E[State database]
C --> E
D --> E
F[Acceptance plan] --> B
F --> C
Technical reviewBest possible solution: Complete the measured reductions inside the existing database owners while preserving consumption, deletion ordering, and retention contracts. Do we have a high-confidence way to reproduce the issue? Current-main source confirms the separate queries targeted by the experiment; no runtime measurement was supplied or executed during this read-only review. Is this the best way to solve the issue? The plan appropriately targets existing owners and preserves their contracts, but implementation and measured results are needed to assess the proposed optimization. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 734822d0d863. TestingProof path: none. SecurityNone. EvidenceWhat I checked:
PR surfaceDocs +18. Total +18 across 1 file. Added test files: 0. View PR surface stats
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 October 24, 2026, 9:19 PM ET / October 25, 2026, 01:19 UTC. |
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. |
|
perf(db): remove redundant consume and deletion probes (openclaw#183069) Consume pairing join codes with dialect-generated DELETE RETURNING, report capture deletion totals from affected-row counts, and embed the progress retention cutoff in its DELETE. Preserve pairing authority, error precedence, expired-code consumption and single use, capture transaction/file ordering, and progress retention. Native and PostgreSQL outcome/count regressions pass; exact-head CI and PostgreSQL review passed. Removes one join consume statement, two capture count statements per request, and one overflow prune statement.
What Problem This Solves
Three owners asked the database for a fact their next write already reports. Pairing redemption now consumes and returns the join-code row in one dialect-generated DELETE RETURNING. Selected capture deletion reports the two DELETE changes counts inside the existing transaction. Progress overflow pruning embeds the ordered cutoff query in the DELETE.
All pairing authority and validation checks remain: success, missing and expired response bytes, rate-limit error precedence, expired/malformed code consumption, and concurrent single use. Capture still deletes event metadata before session metadata, preserves shared blobs, and removes legacy files only after commit. Progress keeps its 200,000-row cap, 1,024-row prune batch, sequence ordering and affected-row cache update. No schema, public API, cache, worker-routing or cross-store commit change.
Preregistered acceptance (before first run)
Base: 285029f. Committed rule: scripts/perf/sql-probe.md.
Synthetic initialized-owner counts must change: join-code consume 3→2 table statements for present/missing/expired outcomes; selected capture deletion removes exactly two COUNTs per nonempty ID request; overflow progress append 5→4 table statements. Worker requests and main-thread work must not increase. Deterministic count regressions must fail on base, pass on candidate; outcome tests pass on both. Keep rollback, single-use, malformed row and exact HTTP response/error precedence tests.
Use isolated Gateway with real transport, frozen observer and three alternating baseline/candidate warm control pairs when admission load is below 64 (otherwise one pair under the loaded-host rule), with five warm target actions per arm; separate cold/warm. Report median/p95/range for repeated actions, statement/request/MAIN totals and operation attribution. Profile per thread with Node. No elapsed-time claim unless timing lock/load<24 and ≥5 interleaved samples per arm. Investigate each ≥20% increase; no 'within spread' exception. PostgreSQL conformance and exact-head review are required before landing.
Evidence
The deterministic regressions failed on unchanged production only on the intended counts; the outcome and retained-state assertions passed. Candidate native capture, progress, real HTTP pairing, worker and async-consumer tests pass (53 tests; one PostgreSQL-only case skipped). SQLite and PostgreSQL join outcomes, PostgreSQL shared-blob deletion and progress retention pass (10 passed, the PostgreSQL-only capture case skipped for the SQLite half). Both independent Codex reviews found no actionable P0–P2 defects; the second covered the complete production patch.
The final head is
4de61b17d3ea1e73c6a7f8a1ce19e1e511f3b1ab, approved by PostgreSQL review. The final shared index contained 2,665 open PRs targeting main. All 80 overlapping heads passed base-only versus base-plus-candidate merge-tree comparisons: no added conflict paths, blocks, messages or changed conflict contents. Current-main merge-tree is clean. All comparisons have zero new conflicts: #183114, #183044, #182971, #182951, #182329, #182216, #182104, #180832, #180026, #178768, #178124, #178033, #177356, #177351, #175345, #175029, #174317, #174235, #173557, #173026, #170160, #169723, #169504, #169438, #169241, #169081, #168522, #168434, #167221, #167090, #166166, #165710, #165583, #164935, #164843, #164721, #164551, #163835, #163655, #163239, #162989, #162583, #162565, #162530, #161997, #161410, #160908, #160851, #159478, #159326, #159255, #158502, #158244, #157693, #157557, #157427, #156634, #155630, #154904, #153907, #153856, #151648, #150078, #149882, #149241, #148533, #146847, #146326, #145839, #141239, #141004, #140609, #139620, #136474, #129388, #126224, #124337, #121204, #107366, #93952.Exact-head CI 40151411023 completed successfully (53 passed, 26 skipped), including all three PostgreSQL shards, types, lint, source contracts/export collisions, architecture/Madge and T1/worker/dialect ratchets. Canonical Knip is unchanged across all three scans: production 75, full-tree 98, scripts 1,136. Focused local lint/format/diff checks passed. A duplicate local check:changed run was stopped during worker inventory after CI supplied the same gates; it is recorded as incomplete, not passed. The original PR-context heading failure was corrected in the body; replacement run 40151662474 passed.
Synthetic Gateway count evidence
One completed baseline/candidate pair exercised all 36 target actions per arm: one cold and five warm samples for six actions, with per-thread Node profiles. Pairing uses real Gateway WebSocket minting and HTTP redemption/replay. Capture uses its production async worker API. No live user state was used.
Cells below show SQL median / p95 [min–max]. Each warm row has five samples per arm; every action has MAIN=0.
Cold redeem/replay each fall 5→4 SQL, shared/final/missing capture fall 8/9/7→6/7/5; requests remain 1 and MAIN=0. Cold mint is 24→23 SQL and 6→5 requests. These are one cold sample per arm, not timing estimates.
Owner attribution across cold and warm actions: join redemption 60→48 SQL over 12 requests; capture deletion 144→108 SQL over 18 requests. Both owners retain exactly the same request count and MAIN=0. The entire target process is 1,395→1,350 SQL, 186→187 requests, MAIN 731→731 (startup included). The difference from the 48 removed owner statements is exactly +1 SQL from unchanged prepared-pool presence and +2 SQL/+1 request from unchanged state-lease acquisition. All other operation totals match.
The frozen control completed successfully at 2,996→3,002 SQL, 802→803 requests, MAIN 96→95. Ten warm control windows have SQL median 50→50, p95 55→68, range [50–55]→[50–68]; requests median 12→12, p95 14→22, range [12–14]→[12–22]; MAIN remains zero. These increases are explicitly retained: warm-window additions are unchanged lease probes/acquisition, plugin catalog/metadata refresh and watched-session reads; first-turn/compaction increases are unchanged worker admission/schema/WAL work moving between phases. Whole-run differences also include periodic proactive-job reads, deletion snapshots and checkpoints, offset by fewer maintenance/list/lifecycle calls. None of the three touched tables is accessed in either control arm. Per-phase and per-operation attribution covers all flagged cells; no warm-performance improvement or timing claim is made.
One candidate target cron SELECT has an empty phase label because the observer read during a phase-file write. It remains counted in the total and explicit unassigned bucket; its phase was not guessed. Native and worker CPU profiles were inspected for owner attribution only, with no CPU-speed claim.
Maintainer-approved acceptance amendment: the remaining two census pairs were waived based on the red-on-base/green-on-head native and PostgreSQL count regressions and exact-head green CI. The already-started second baseline was stopped during its build, before measured actions; it contributes no samples. The completed first pair and all its adverse cells are disclosed above. No schema, authority or durability gate was waived.
Production delta: 28 fewer lines. Tests/registry grow by 309 lines and workload/docs by 296 lines for deterministic counts, both-engine behavior proof and a rerunnable transport workload.