You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Daemon reads all queue on one SQLite reader connection #391
Store::read sends every reader job to a single reader connection (src/store.rs, Reader). About 20 kinds of read go through it: history_search, history pages and turn lists, list, prompts, items_by_ids, usage, and others. Writes go to the separate writer and are not affected. Reads, though, run one at a time, so one slow read makes every other bot's read wait behind it.
The longest such read today is a history search. One page reads up to 64 MiB of items. On a synthetic store of 800 to 4,000 bots (up to 1 GB), a search for text that is nowhere takes about 0.3 s per page after the fix in #380, and took 1.6 s before it. While a page runs, a list from Sonny or a history read from another agent waits. With many agents searching at once, those waits stack.
Proposal
Use a small pool of reader connections, one per CPU, each a WAL reader like the current one. Jobs go to whichever connection is free. This is the standard setup for SQLite in WAL mode: readers don't block each other or the writer, and each read sees a consistent snapshot. A read that has to see the caller's own write is already sent to the writer, so that rule doesn't change.
To check:
Per-connection statement caches multiply by the pool size. Measure the memory.
Job counters per label stay the same.
A bench with N concurrent searches plus a stream of list calls should show list latency before and after.
This is a daemon change, so it is to be discussed before any code.
Activity
Daemon: reads that decide nothing run beside the service loop, on a r…