Skip to content

perf(daemon): reduce live catch-up amplification - #1430

Merged
Sinity merged 1 commit into
masterfrom
feature/perf/daemon-runtime-followup
May 23, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/perf/daemon-runtime-followup

Conversation

@Sinity

@Sinity Sinity commented May 23, 2026 •

Copy link
Copy Markdown
Owner

Summary

Reduce live daemon catch-up amplification found during production deployment of #1429. The change keeps daemon full-ingest parsing in-process by default, raises bounded append-tail ingestion to 64 MiB, removes an expensive FTS5 virtual-table count from direct polylogue status fallback, and treats client disconnects during daemon HTTP responses as normal disconnects rather than noisy internal errors.

Problem

After deploying Polylogue bdc1d724 through Sinnix, the live daemon no longer hit the previous 6 GiB restart pattern in the first catch-up phase, but real workload still showed avoidable amplification: a forkserver/resource-tracker child remained after live full ingest, a large Codex append fell back into full-session reprocessing, polylogue --plain status hung on the production archive fallback path, and timed-out status probes generated BrokenPipe tracebacks in daemon logs.

Solution

  • Default live full-ingest worker count to 1 unless POLYLOGUE_LIVE_FULL_INGEST_WORKERS explicitly opts into process workers.
  • Allow append plans up to 64 MiB so large live Codex tails remain append-only instead of becoming full-session rewrites.
  • Count FTS readiness in direct status fallback via messages_fts_docsize, not COUNT(*) FROM messages_fts.
  • Treat BrokenPipeError / ConnectionResetError from daemon handlers as client disconnects, not internal errors.
  • Add regression coverage for the status SQL path, live worker-count default, and disconnect handling.

Verification

  • pytest tests/unit/cli/test_status.py tests/unit/sources/test_live_watcher.py -q --tb=short -> 72 passed in 13.86s
  • pytest tests/unit/daemon/test_daemon_http_security.py tests/unit/cli/test_status.py tests/unit/sources/test_live_watcher.py -q --tb=short -> 258 passed in 16.40s
  • ruff format --check polylogue/sources/live/batch_support.py polylogue/cli/commands/status.py tests/unit/sources/test_live_watcher.py tests/unit/cli/test_status.py -> 4 files already formatted
  • ruff check polylogue/sources/live/batch_support.py polylogue/cli/commands/status.py tests/unit/sources/test_live_watcher.py tests/unit/cli/test_status.py -> All checks passed
  • mypy polylogue/sources/live/batch_support.py polylogue/cli/commands/status.py tests/unit/sources/test_live_watcher.py tests/unit/cli/test_status.py -> Success: no issues found
  • mypy polylogue/daemon/http.py tests/unit/daemon/test_daemon_http_security.py -> Success: no issues found
  • pre-push devtools verify --quick -> all checks passed (36.6s total)

@coderabbitai

coderabbitai Bot commented May 23, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

@Sinity, we couldn't start this review because you've used your available PR reviews for now.

Your plan currently allows 1 review/hour. Refill in 11 minutes and 15 seconds.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more review capacity refills, 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 trial, open-source, and free plans. In all cases, review capacity refills continuously over time.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: c65e67a2-1244-4bd0-addd-ed1233acb032

📥 Commits

Reviewing files that changed from the base of the PR and between bdc1d72 and 4ac67ed.

📒 Files selected for processing (6)
  • polylogue/cli/commands/status.py
  • polylogue/daemon/http.py
  • polylogue/sources/live/batch_support.py
  • tests/unit/cli/test_status.py
  • tests/unit/daemon/test_daemon_http_security.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/daemon-runtime-followup

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.

Keep live full-ingest in-process by default so daemon catch-up does not leave a forkserver/resource-tracker pair around after small batches. Expand bounded append tails to 64 MiB so large live Codex appends do not fall back to full-session reprocessing.\n\nAlso make direct status fallback count FTS rows through the docsize shadow table instead of COUNT(*) on the FTS5 virtual table, which can hang on production-size archives.
@Sinity
Sinity force-pushed the feature/perf/daemon-runtime-followup branch from 9d2d3e1 to 4ac67ed Compare May 23, 2026 10:17

@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: 9d2d3e1daa

ℹ️ 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 tests/unit/cli/test_status.py Resolved
@Sinity
Sinity merged commit dd9f200 into master May 23, 2026
6 checks passed
@Sinity
Sinity deleted the feature/perf/daemon-runtime-followup branch May 23, 2026 10:20
@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.

  • 79.F045 / P2: stale at the checked revision: The former _fast_fts_doc_count helper and its substring-based guard are absent at the pin. The replacement FTS count SQL explicitly targets messages_fts_docsize at polylogue/storage/fts/sql.py:140, while tests/unit/cli/test_status.py:293 tests the daemon-reported coverage projection rather than the removed guarded query.

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