feat: SQLite VFS Pool - share WASM instances across actors#4454
feat: SQLite VFS Pool - share WASM instances across actors#4454NathanFlurry wants to merge 27 commits intomainfrom
Conversation
…ebAssembly.Module
Added US-018 through US-032 covering bugs found during adversarial review: prefix collision in forceCloseByFilePrefix, Database.close() idempotency, WASM promise rejection caching, trackOp coverage gaps, concurrent acquire() burst duplication, and more. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
🚅 Deployed to the rivet-pr-4454 environment in rivet-frontend
|
PR Review: SQLite VFS PoolThis is a substantial and well-designed PR that solves a real memory problem. The adversarial review process (US-018 through US-032) shows careful attention to edge cases. Here are my observations: Must Address Before Merging1. The 2. US-027 through US-032 have The Code Concerns3. Despite being named 4. Short name exhaustion under repeated poisoning When an actor closes uncleanly, its short name is "poisoned" and never reused. If actors crash frequently enough, a 5. Mutex scope narrowing in The mutex is now scoped only to guard the 6. WASM module cache — failed compilation not cleared In this.#wasmModuleCache = WebAssembly.compile(wasmBuffer).catch(err => {
this.#wasmModuleCache = undefined;
throw err;
});Positive Observations
Minor
Overall this is a solid change that addresses a meaningful operational problem. The main blockers are removing the |
Summary
SqliteVfsPoolto share WASM SQLite instances across multiple actors, reducing memory from ~16.6 MB per actor to ~16.6 MB per 50 actors (200 actors: 3.3 GB -> 66 MB)ActorDriver.createSqliteVfs(actorId)interface changeKey changes
@rivetkit/sqlite-vfs:SqliteSystemsupports multiple registered files,SqliteVfssupports multiple open databases per instance, newSqliteVfsPoolandPooledSqliteHandleclassesrivetkitdrivers:ActorDriver.createSqliteVfs()now acceptsactorId, FS and engine drivers use poolISqliteVfsinterface: Extracted for interchangeable use ofSqliteVfsandPooledSqliteHandleTest plan
cd rivetkit-typescript/packages/sqlite-vfs && npx tsc --noEmitto verify typecheckpnpm test driver-file-system🤖 Generated with Claude Code