Web: In-memory connection pool - #1041
Open
simolus3 wants to merge 13 commits into
Open
Conversation
🦋 Changeset detectedLatest commit: 3253a06 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
simolus3
force-pushed
the
web-statement-cache
branch
from
July 21, 2026 10:01
b3d72f1 to
ce91dfe
Compare
simolus3
force-pushed
the
web-statement-cache
branch
from
August 6, 2026 06:54
ce91dfe to
b152535
Compare
simolus3
marked this pull request as ready for review
August 6, 2026 15:09
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As a follow-up to #1029 adding support for in-memory databases (see in particular the discussion in #1029 (comment)), this adds a multi-threaded variant of the in-memory file system with support for concurrent reads / writes.
This is a fairly specialized VFS, relevant where persistence is not required but fast and parallel queries are. As most users probably need this this, this is exported separately (as
@powersync/web/extra/shared-memory-pool), which ensures this doesn't impact default bundle sizes.To use this,
import { InMemoryWriteAheadLogPool } from '@powersync/web/in-memory-wal-experiment';and open PowerSync databases with theopened: new InMemoryWriteAheadLogPool({ numWorkers: 2 })option.This implementation avoids navigator locks and and doesn't give databases a name, each instance is a fresh and completely independent database file. It does require shared memory and cross-origin isolation though. For the most part, this VFS works like the OPFS write-ahead VFS, except that:
Mapwe can send between workers. This avoids checksums and other complex state tracking.Semaphoreinstead.memcpy, so fairly fast overall. We could parallelize these copies by delegating them to workers, but that feels like a premature optimization at this point.This shares the local connection state management with the OPFS write-ahead pool. I have also tested this VFS in the react supabase todolist demo.
AI use: Mostly manual, I used Claude for reviews and minor correctness / concurrency fixes.