Run the Obsidian sync off the event loop and delete chunks by containment #84
Reference in New Issue
Block a user
Delete Branch "perf/obsidian-sync-off-loop"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The periodic Obsidian sync (
OBSIDIAN_CONTINUOUS_SYNC, every 60s by default) walked the vault, statted and read files, and ran synchronous SQLAlchemy queries and deletes directly on the event loop. While it ran, every active chat stream froze.asyncio.to_thread. Embedding stays async.cmetadata @> CAST(:filter AS jsonb)), which langchain_postgres'six_cmetadata_ginindex (jsonb_path_ops) supports. The oldcmetadata->>key = valuecouldn't use it. A sync pass deletes all stale files in one transaction.Not done, deliberately:
embedding, so similarity search is a brute-force scan. That's fine up to roughly tens of thousands of chunks; consider HNSW past ~100k (needs a migration).index_obsidian_documents) still walks the vault on the loop. It's manual, not periodic.Review: Sonnet worker plus two review rounds. Round 1 found the cache-before-delete ordering bug, which now has a regression test, and asked for the GIN and HNSW findings. Round 2 was clean.
558 unit tests, Ruff.
🤖 Generated with Claude Code