Skip to content

livesync-bridge: run as one-way CouchDB→disk materializer (kill idle polling CPU) - #175

Merged
AlienWalker1995 merged 1 commit into
mainfrom
tune/livesync-bridge-one-way-materializer
Aug 12, 2026
Merged

livesync-bridge: run as one-way CouchDB→disk materializer (kill idle polling CPU)#175
AlienWalker1995 merged 1 commit into
mainfrom
tune/livesync-bridge-one-way-materializer

Conversation

@AlienWalker1995

Copy link
Copy Markdown
Owner

Problem

The livesync-bridge sat at ~128% CPU continuously (aggressive fan), even with nothing changing. Cause: the bridge watches the notes/ folder to push host/AI disk edits back up to CouchDB, but 9p bind mounts emit no inotify events, so the only way to catch disk writes is CHOKIDAR_USEPOLLING=1 — chokidar stat()s every file every 3s. On this ~5,260-file vault that's ~100k stat calls/minute over the slow Windows↔VM boundary, pinning a core forever.

Fix

Default the bridge to a one-way CouchDB→disk materializer (CHOKIDAR_USEPOLLING=0):

  • CouchDB → disk keeps working — it's network-driven (the couchdb peer's live changes feed), not polling-based. Device edits still materialize to notes/ promptly, so rag-ingestion → qdrant and the memory-vault MCP keep seeing your notes.
  • disk → CouchDB is dropped — chokidar sits on inotify, gets no events on 9p, ~0 idle CPU. This direction is only needed if you edit notes directly on the host filesystem (not via an Obsidian app), which the AI-RAG use case doesn't.

CHOKIDAR_INTERVAL bumped 3s → 15s as a saner large-vault default for anyone who re-enables polling.

Validated

  • Idle CPU ~128% → ~0.00% (sustained over several minutes after the one-time startup scan).
  • Mirror holds at 5,260 files — CouchDB→disk unaffected.
  • rag-ingestion continues embedding notes into the qdrant documents collection (1,883 vectors).

Re-enable bidirectional

Set CHOKIDAR_USEPOLLING=1 (INTERVAL controls the poll period) only if you edit notes directly on the host FS and need those pushed back up to CouchDB.

🤖 Generated with Claude Code

…R_USEPOLLING=0)

The bridge exists to feed the AI stack: CouchDB -> notes/ files so rag-ingestion
(qdrant) + the memory-vault MCP can read the vault. That direction is network-driven
and free. The reverse (disk -> CouchDB) needs a file watcher, but 9p bind mounts emit
no inotify events, so catching host/AI disk writes requires chokidar POLLING every
file every few seconds — on this ~5,260-file vault that stats ~100k files/min and
pegs a core continuously (~128% CPU idle, aggressive fan), even when nothing changes.

The AI-RAG use case never needs disk -> CouchDB (humans edit on devices, which sync
to CouchDB over the network; device -> CouchDB -> file materialization is unaffected).
So default to polling OFF: chokidar sits on inotify, gets no events on 9p, ~0 idle CPU,
while CouchDB -> disk keeps working. Validated: idle CPU ~128% -> ~0%, mirror holds at
5,260 files, rag-ingestion keeps ingesting. Set CHOKIDAR_USEPOLLING=1 (INTERVAL now 15s,
a saner large-vault default than 3s) only if you edit notes directly on the host FS and
need those pushed back up to CouchDB.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@AlienWalker1995
AlienWalker1995 merged commit f6fcb9f into main Aug 12, 2026
2 of 3 checks passed
@AlienWalker1995
AlienWalker1995 deleted the tune/livesync-bridge-one-way-materializer branch August 12, 2026 02:45
AlienWalker1995 added a commit that referenced this pull request Aug 12, 2026
…rite workflow) (#176)

PR #175 defaulted the bridge to one-way (CouchDB->disk only) for a pure-RAG read use
case. But agents (Hermes/Claude) and host edits write docs INTO notes/ and need them to
flow UP to CouchDB -> devices, which one-way disabled. Restore bidirectional, but at a
60s poll interval instead of the original 3s: polling stats every file each tick, so 3s
on a ~5k-file vault pegged a core (~128% CPU), while 60s keeps the write workflow
(updates reach CouchDB within a minute) at ~6% CPU.

Validated: a file written into notes/ reached CouchDB within the poll window; idle CPU
is a fraction of the 3s figure. Set USEPOLLING=0 for a read-only mirror at ~0 CPU if
nothing writes to notes/ host-side.

Co-authored-by: Hermes Bot <hermes@ordo-ai-stack.local>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
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