perf(db): size the pool to cover every DB consumer

POOL_SIZE = 4 was the process-wide cap on concurrent DB operations while 4 queue workers, 8 URL workers, dispatcher handlers and the sweep all share the pool — WAL readers queued behind writers and every hot-path round trip (3-5 per message) contended for four permits. 16 covers every consumer at once; SQLite's single writer serializes writes regardless.
This commit is contained in:
2026-09-24 00:48:29 +08:00
parent 33b1f04f0e
commit 5d44946690
2 changed files with 6 additions and 4 deletions
+5 -3
View File
@@ -17,9 +17,11 @@ use std::sync::Arc;
use std::time::Duration;
/// Upper bound on pooled (reused) connections and on concurrent DB
/// operations per store. Small on purpose: the queue's `BEGIN IMMEDIATE`
/// leases serialize writes anyway, and WAL readers rarely need more.
const POOL_SIZE: usize = 4;
/// operations. Sized to cover every consumer at once — 4 queue workers +
/// 8 URL workers, plus dispatcher handlers and the sweep — so the semaphore
/// stops queueing operations behind each other; SQLite's single writer
/// serializes writes regardless, and WAL readers rarely block.
const POOL_SIZE: usize = 16;
/// A tiny connection pool for one SQLite file. Connections are checked out
/// on a blocking thread and returned afterwards; `acquire` opens a new