From db53b114cb41fa693ac9d33f01d07e5514f77e4f Mon Sep 17 00:00:00 2001 From: Gareth George Date: Sun, 3 May 2026 12:32:35 -0700 Subject: [PATCH] better sqlitestore prewarming --- internal/oplog/sqlitestore/prewarm.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 internal/oplog/sqlitestore/prewarm.go diff --git a/internal/oplog/sqlitestore/prewarm.go b/internal/oplog/sqlitestore/prewarm.go new file mode 100644 index 00000000..6f1ab3bb --- /dev/null +++ b/internal/oplog/sqlitestore/prewarm.go @@ -0,0 +1,16 @@ +package sqlitestore + +import ( + "github.com/ncruces/go-sqlite3" + _ "github.com/ncruces/go-sqlite3/embed" +) + +// init kicks off wazero's compilation of the embedded SQLite WASM binary in +// the background. The compile is guarded by a sync.Once inside go-sqlite3, so +// any later sql.Open call simply waits on the same Once if it isn't done yet. +// The goal is to move this multi-second cost off the critical path of the +// first sqlite open, which otherwise inflates startup latency and burns into +// per-test deadlines (notably under -race). +func init() { + go sqlite3.Initialize() +}