Repository navigation
perf(daemon): update append stats incrementally - #1470
Conversation
Live catch-up after the FTS hot-path fix still showed severe physical reads while source payload reads stayed tiny and FTS freshness rows were ready. The remaining append path always ran a full conversation_stats recount after each tiny live tail append, forcing large active conversations back through a broad messages scan.\n\nMove append stats maintenance into a focused helper that reuses existing message signatures, applies deltas for changed tail messages, and falls back to the full recount only when the stats row is missing. Preserve missing-stats repair for unchanged append replays while keeping non-append writes on the existing full path.\n\nFocused verification:\n- pytest -q tests/unit/pipeline/test_ingest_append_replay.py tests/unit/pipeline/test_ingest_batch.py -> 29 passed\n- mypy polylogue/pipeline/services/ingest_batch/_core.py polylogue/pipeline/services/ingest_batch/_append_stats.py tests/unit/pipeline/test_ingest_append_replay.py -> success\n- devtools verify --quick -> exit_code 0\n\nRef #1447
|
Caution Review failedPull request was closed or merged during review 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 (5)
📝 WalkthroughWalkthroughThis PR refactors append-mode conversation statistics updates in the ingest batch pipeline. A new ChangesAppend-mode Conversation Stats Refactoring
🎯 3 (Moderate) | ⏱️ ~25 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 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 65d916cb4f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Summary Skip post-write message/action FTS repair when live FTS triggers were already present for the write. Problem After #1470 and #1471 were deployed, live validation still showed `polylogued` reading about `2.34 GB` over 10 seconds with IO full avg10 around `20%`, while logs showed hot insight rebuilds were deferred and append writes were small. The remaining broad path was `commit_archive_write_effects`: it always called `repair_message_fts_index_sync` and `repair_action_fts_index_sync` for changed conversations. On normal live writes the FTS triggers already maintain those rows, so the repair did a redundant delete/reinsert of the whole conversation FTS surface after every append. Solution - Record whether message/action FTS triggers were present before write side effects run. - Always call `ensure_fts_triggers_sync` to restore missing triggers. - If triggers were already live, trust them and skip the redundant repair. - If triggers were missing or suspended, keep the existing targeted repair path after trigger restoration. - Add tests for both paths. This keeps the hard FTS freshness contract: live-triggered writes stay fresh immediately, and missing/suspended triggers still force repair. Ref #1447 Verification - `pytest -q tests/unit/archive/test_write_gateway.py tests/unit/pipeline/test_ingest_append_replay.py` -> `9 passed in 0.20s` - `mypy polylogue/archive/write_effects.py tests/unit/archive/test_write_gateway.py` -> `Success: no issues found in 2 source files` - `devtools verify --quick` -> `exit_code 0`, `total_duration_s 39.71` - pre-push `devtools verify --quick` -> `exit_code 0`, `total_duration_s 34.62`
|
Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.
Only the rows listed above are dispositioned. Held findings remain open. |
Summary
Update daemon append writes so conversation stats are maintained from changed tail-message deltas instead of recounting every message in the conversation after each append.
Problem
After #1469 was deployed, live catch-up still produced severe physical reads even though source payload reads were tiny, FTS freshness rows were ready, and hot insight rebuilds were being deferred. The remaining broad read was the append write path:
_append_conversationalways called_upsert_stats_from_messages, which scans the fullmessagesset for the active conversation after every tiny append.Live evidence from the deployed daemon:
11886files and needed309files /508.6 MB;readyfor the live surfaces;/proc/$pid/ioover 10s still showed1,440,432,128read bytes;source_payload_read_byteswhileinput_bytesrepeated huge source-file sizes.Solution
polylogue/pipeline/services/ingest_batch/_append_stats.pyfor append-only stats helpers.conversation_statsrow is missing, including unchanged append replays that need stats repair.Ref #1447
Verification
pytest -q tests/unit/pipeline/test_ingest_append_replay.py tests/unit/pipeline/test_ingest_batch.py->29 passed in 0.24smypy polylogue/pipeline/services/ingest_batch/_core.py polylogue/pipeline/services/ingest_batch/_append_stats.py tests/unit/pipeline/test_ingest_append_replay.py->Success: no issues found in 3 source filesdevtools verify --quick->exit_code 0,total_duration_s 38.25devtools verify --quick->exit_code 0,total_duration_s 36.11Summary by CodeRabbit
Release Notes
Bug Fixes
Tests
Documentation