perf(query): optimize snapshot decision hot path (<100ms)#322
Open
perf(query): optimize snapshot decision hot path (<100ms)#322
Conversation
…313) 5 instances in bg_scan.rs and issue_proposal.rs used .unwrap() on path.parent() which could panic on root paths. Replaced with .context()? for graceful error propagation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add composite indexes for hot path queries: - idx_decisions_active_domain_branch on (is_active, domain, branch) - idx_decisions_active_domain on (is_active, domain) - Add LIMIT parameter to active_decisions to prevent full table scans - Add tracing for query latency monitoring - Add benchmark test verifying queries complete in < 1ms - Fix pre-existing bug in migrate_v1_to_v2 (scope column not yet exists) Benchmark results: avg_all=0.34ms, avg_domain=0.30ms (requirement: < 100ms) Closes #319
Owner
Author
Code Review: PR #322Thanks for the implementation work — I reviewed the full diff against issue #319 scope. SummaryThis PR contains the intended hot-path snapshot optimizations, but it also includes unrelated files and a committed secret, which are blocking issues. The scoped changes in FindingsBlockers
Suggestions
Four-Point Check
VerdictChanges Requested Reviewed by edda AI |
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
decide_snapshots(village_id, decision_type, created_at DESC)query_snapshotswith fixed SQL paths, preserve LIMIT/OFFSET, and add hot-path latency warning logs/api/snapshotscaching to per-village recent-100 (TTL 5 min), with in-memory filter/pagination and new regression testsCloses #319