fix(sqlite): remove cache_size and mmap_size PRAGMAs (#2120)

A 64 MB page cache plus a 256 MB memory-mapped region inflate RSS and
cause page-cache thrashing on small (~1 GB) instances. The PRAGMAs were
added to reduce event-loop blocking on TraefikConfigManager JOINs but
the memory cost outweighs the I/O benefit on the deployment shapes that
hit #2120. Leave SQLite on its conservative defaults.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Josh Voyles
2026-06-13 14:53:07 -04:00
committed by Owen
parent e5e7b79712
commit a55fb21e53

View File

@@ -60,13 +60,9 @@ function createDb() {
// retry loops that accumulate memory. // retry loops that accumulate memory.
sqlite.pragma("busy_timeout = 5000"); sqlite.pragma("busy_timeout = 5000");
// 64 MB page cache (default 2 MB) — reduces I/O round-trips on large // Intentionally NOT setting cache_size or mmap_size: a large page cache plus
// TraefikConfigManager JOINs that block the event loop. // a multi-hundred-MB mmap region inflate RSS and cause page-cache thrashing
sqlite.pragma("cache_size = -65536"); // on small (~1 GB) instances. Leave SQLite on its conservative defaults.
// 256 MB memory-mapped I/O — OS serves reads from page cache directly,
// reducing event-loop blocking.
sqlite.pragma("mmap_size = 268435456");
// Wrap prepare() so every drizzle-orm statement is auto-finalized after // Wrap prepare() so every drizzle-orm statement is auto-finalized after
// first use, preventing sqlite3_stmt accumulation between GC cycles. // first use, preventing sqlite3_stmt accumulation between GC cycles.