Skip to content

perf(daemon): skip inode-churn catch-up rehash - #1034

Merged
Sinity merged 1 commit into
masterfrom
feature/perf/catchup-stable-stat-fastpath
May 15, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/perf/catchup-stable-stat-fastpath

Conversation

@Sinity

@Sinity Sinity commented May 15, 2026

Copy link
Copy Markdown
Owner

Summary

Avoid full-file fingerprint reads during daemon catch-up when a source path has the same byte size and an existing content fingerprint but its device/inode changed under the cursor.

Problem

The deployed daemon still hammered disk after #1033. py-spy dump showed startup stuck in fingerprint_file() from LiveWatcher._plan_catch_up(). A production cursor classification found 10,916 files / 31.35 GB in the fingerprint_read path solely because stored st_dev/st_ino no longer matched the filesystem, even though paths, sizes, parser fingerprints, and stored content fingerprints were stable.

Solution

Treat stable path + stable byte size + recorded content fingerprint as the catch-up skip path independent of inode/device churn. Appends still trigger work via size > byte_offset, truncations still fall through, and legacy cursors without fingerprints still populate cursor state.

Verification

  • pytest tests/unit/sources/test_live_watcher.py -q --tb=short → 60 passed
  • pytest tests/integration/test_live_read_amplification.py -q --tb=short → 5 passed
  • ruff check polylogue/sources/live/watcher.py tests/unit/sources/test_live_watcher.py → All checks passed
  • devtools verify-file-budgets → clean
  • devtools render-all → generated surfaces refreshed
  • Production classifier after the patch: 10,913 files / 31.32 GB move to fast_skip; residual append is 3 files / 27.7 MB.

Problem: live catch-up trusted recorded fingerprints only when device and inode still matched. After mount or home-state churn, production had 10,916 unchanged files classified for full fingerprint reads, forcing about 31 GB of startup rehash work before useful ingest could begin.\n\nWhat changed: treat stable path + stable byte size + existing content fingerprint as the hot skip path, independent of inode/device changes. Appends and truncations still trigger work by size/offset, and files without fingerprints still populate cursor state.\n\nVerification: pytest tests/unit/sources/test_live_watcher.py -q --tb=short; pytest tests/integration/test_live_read_amplification.py -q --tb=short; ruff check polylogue/sources/live/watcher.py tests/unit/sources/test_live_watcher.py
@coderabbitai

coderabbitai Bot commented May 15, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@Sinity has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 10 minutes and 24 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: ca896fbb-ab6f-4368-a36a-b91053c72a4c

📥 Commits

Reviewing files that changed from the base of the PR and between a73d69b and f74566e.

📒 Files selected for processing (5)
  • AGENTS.md
  • docs/test-quality-workflows.md
  • docs/verification-catalog.md
  • polylogue/sources/live/watcher.py
  • tests/unit/sources/test_live_watcher.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/perf/catchup-stable-stat-fastpath

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Sinity
Sinity merged commit d1fc26b into master May 15, 2026
4 checks passed
@Sinity
Sinity deleted the feature/perf/catchup-stable-stat-fastpath branch May 15, 2026 01:31

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f74566e19a

ℹ️ 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".

Comment thread polylogue/sources/live/watcher.py Resolved
Sinity added a commit that referenced this pull request May 15, 2026
## Summary

Use the indexed `action_events` base 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-spy` showed the remaining busy thread inside
`_action_fts_has_rows_for_conversations`, which queried
`action_events_fts` by `conversation_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.93s`
- `ruff check polylogue/daemon/convergence_stages.py
tests/unit/daemon/test_convergence_stages.py` → `All checks passed!`
- Push hook quick baseline → `exit_code: 0`
- Production query-plan check: `EXPLAIN QUERY PLAN SELECT 1 FROM
action_events WHERE conversation_id IN (...) LIMIT 1` → `SEARCH
action_events USING COVERING INDEX idx_action_events_sort`

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Bug Fixes**
* Improved the reliability and accuracy of search index maintenance for
action events by enhancing how the system determines when repairs are
necessary.

<!-- review_stack_entry_start -->

[![Review Change
Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/Sinity/polylogue/pull/1035)

<!-- review_stack_entry_end -->

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@Sinity

Sinity commented Oct 1, 2026

Copy link
Copy Markdown
Owner Author

Historical Codex triage: evidence checked at 5ebcfe5. This records that source revision; it does not claim a fresh review of current master.

  • 70.F078 / P1: fixed-already at the checked revision: The same-size fast path now requires the recorded observation to match at polylogue/sources/live/watcher.py:751. A changed observation reaches a full accepted-prefix hash comparison, and line 813 returns work when that prefix changed instead of accepting a replacement inode solely because its size matches.

Only the rows listed above are dispositioned. Held findings remain open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant