Repository navigation
perf(sessions): avoid idle scans of deferred relation receipts - #4810
ScriptedAlchemy wants to merge 11 commits into
Conversation
Probe the indexed next relation recovery deadline before reading the creation-order journal, and detect one extra due receipt so the bounded recovery worker continues without missing backlog. Extend database-backed recovery regressions for deferred idle reads, due-page continuation, and settled quiescence. Refs #4481
|
The shared bounded_query_limit helper already requests one sentinel row for has_more. Do not pad the caller's limit a second time. Refs #4481
The bounded query helper already fetched limit plus one before this PR. Keep the behavior regression and describe what it actually proves. Refs #4481
The one-row recovery pagination regression reused an applied receipt while setting its state to pending. The actual SQLite schema refuses that mixed state unless graph_watermark and applied_at are cleared in the same update. Restore the valid pending transition without weakening the receipt constraint or the two-page recovery and idle-queue assertions. Refs #4481
There was a problem hiding this comment.
🔍 Devin Review: 1 flag
Not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
Repair three hosted automation_runner_test failures by supplying the configured executable identity required by the production prefilter. Use the same identity for the prefilter and retained runner, preserving manual-schedule, exact-ledger, live-lock and lock-race assertions. Add a production-prefilter regression for unconfigured refusal, deduplication and same-occurrence recovery after binding, with zero backend calls and no effectful terminal. Do not relax backend admission, change timeouts, or alter the graph publication changes. Refs #4532
|
Review/ownership blocker before merging this #4481 slice: the PR head advanced from |
A synchronous OnceLock wait inside the asynchronous historical-ingest fixture blocked the worker that must poll live projection concurrently. Use a durable async watch latch to preserve release ordering while exercising the real interleaving and supersession journey. Refs #4481
|
Published |
Scope — Refs #4481 (partial, not closure)
The idle daemon's retained-summary pass calls relation-receipt recovery even when every pending receipt is asleep until a future retry deadline. The existing recovery SELECT orders by
created_atand SQLite choosesidx_session_relation_receipts_pending, walking the sleeping pending prefix despite finding no due rows.Fix: Use the existing covering
idx_session_relation_receipts_recovery_duethrough a cheapMIN(recovery_next_attempt_at)eligibility probe in the same snapshot. When there is no due work, return a truthful empty page with the persisted next deadline, without reading or joining the old deferred journal rows. Keep creation-order processing for actually due work and preserve cancellation, typed errors, and the existing delayed retry outcomes.Pagination audit: The shared
bounded_query_limit(limit)already requestslimit + 1rows for itshas_moresentinel. Review found that the first patch accidentally added an additional increment, fetchinglimit + 2; follow-up commitb1be997removes that double padding. The existing pagination semantics are retained and covered by the two-page regression; no pre-existinghas_moredefect is claimed.Regression coverage
Extend the existing real registered-store recovery journey in
crates/tracedecay-session-runtime/src/lcm_effects/tests.rs:limit=1pages; the first page must reporthas_more=true, the secondfalse.Only two files change, with no schema/dependencies/configuration changes. This is separate from owner PR #4808 (LCM dirty-invalidation backoff) and peer-owned projection, storage, retention and recovery PRs.
Measured SQL evidence and verification limit
A disposable synthetic SQLite fixture containing 75,000 pending, future-deferred relation receipts, using the production index definitions, reported a median of 9.03 ms for the existing creation-order empty candidate SELECT versus 0.0051 ms for the covering-index MIN probe (25 repetitions; local host). EXPLAIN showed the former using
idx_session_relation_receipts_pendingand the latter usingidx_session_relation_receipts_recovery_due. These are isolated query measurements, not proof of the reported macOS 170–300% idle CPU cause or an end-to-end daemon benchmark.The query/page code was reviewed against
bounded_query_limiton the exact branch head; no workspace Bazel run was available. Exact-head repository Bazel Rust tests, CI, independent review and a native macOS idle/24-hour store growth acceptance run remain required; the authoring environment has no Bazel or native daemon. No Cargo was used. Do not merge until nonvacuous Bazel tests and review pass.#4481 stays open until idle CPU, repeated retries and bounded growth are proven against master. Held draft #4776, Kev/decision-model work and read-only release #4763 were not modified.