Repository navigation
perf(daemon): use indexed action FTS probe - #1035
Conversation
Problem: live catch-up convergence checked action_events_fts directly to decide whether to repair or insert action FTS rows. On the production archive that probe sat inside the FTS virtual table during catch-up, keeping the daemon in heavy SQLite reads after the source-file rehash path was fixed. What changed: probe the indexed action_events base table by conversation_id instead. Repairing from the base table still converges the full action FTS state, but the decision no longer requires scanning the FTS table. Verification: - pytest tests/unit/daemon/test_convergence_stages.py -q --tb=short - ruff check polylogue/daemon/convergence_stages.py tests/unit/daemon/test_convergence_stages.py - EXPLAIN QUERY PLAN SELECT 1 FROM action_events WHERE conversation_id IN (...) LIMIT 1 -> uses covering index
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR refactors the FTS action-event repair decision logic in ChangesAction-event FTS repair base table check
🎯 2 (Simple) | ⏱️ ~12 minutes
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Use the indexed
action_eventsbase table to decide whether changed conversations have action rows before repairing action-event FTS during daemon convergence.Problem
After #1034 removed the full source-file rehash path, the live production daemon still accumulated heavy reads while converging changed files.
py-spyshowed the remaining busy thread inside_action_fts_has_rows_for_conversations, which queriedaction_events_ftsbyconversation_id. On the production archive this behaves like an FTS-table scan during catch-up.Solution
The repair decision now probes
action_events(conversation_id)instead. That table has normal indexes, and the production query plan uses a covering index. The daemon still repairs or inserts the full action FTS rows from the persisted base data; only the existence probe changes.Verification
pytest tests/unit/daemon/test_convergence_stages.py -q --tb=short→10 passed in 7.93sruff check polylogue/daemon/convergence_stages.py tests/unit/daemon/test_convergence_stages.py→All checks passed!exit_code: 0EXPLAIN QUERY PLAN SELECT 1 FROM action_events WHERE conversation_id IN (...) LIMIT 1→SEARCH action_events USING COVERING INDEX idx_action_events_sortSummary by CodeRabbit