perf(lcm): bound retention diagnostics - #507
Draft
HashemKhalifa wants to merge 4 commits into
Draft
Conversation
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
lcm_doctorretention mode run only the retention diagnostic instead of unrelated payload, FTS, lifecycle, cleanup, and GC checksRoot cause
Retention mode reused the complete doctor diagnostic pipeline and aggregated the full raw-message and summary stores before returning candidates.
LIMITwas applied only after those aggregations, so the work performed still grew with the complete session history.Before and after
LIMIT 1presence probes, only for completely sampled sessionsapply=trueWhy this should perform better
The previous cost was proportional to the amount of stored history because the database had to complete full grouped aggregations before it could apply the result limit. The new retention-only path is proportional to explicit fixed budgets: 21 registry rows, 10,000 analyzed raw messages plus at most 20 sentinels, and at most 20 summary-presence probes. That bounds CPU and disk I/O while returning conservative, auditable coverage metadata when the store is larger than the budget.
Unscoped retention diagnosis can intentionally omit sessions beyond the first 20 or sessions whose raw messages exceed their share of the scan budget. Callers can detect this through
scan_truncated,session_scan_truncated,incomplete_session_count, andincomplete_sessions.Follow-up TODOs before ready for review
The current implementation is a safe bounded first-result path, not the intended final exhaustive-retention design. Keep this PR in draft until these items are resolved or explicitly moved to a separately linked follow-up:
complete=trueonly after the requested scope has been exhaustively covered; otherwise return explicit progress and continuation metadata.Validation metrics
cargo fmt --checkpassedgit diff --checkpassedship, no findingsNo wall-clock speedup is claimed here because a trustworthy isolated, matched before/after benchmark was not completed. The performance claim is the exact algorithmic/query bound above, backed by adversarial tests rather than cache-sensitive timing.