Hybrid OPFS/IndexedDB VFS could be (almost) WAL-like #88
rhashimoto
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Here's another random idea. An OPFS VFS, like AccessHandlePoolVFS, could create a mirror of its database file in IndexedDB with the same versioned page scheme that IDBBatchAtomicVFS uses. I wouldn't expect that to be a big drag on performance - maybe negligible - because the writes to IndexedDB would be fire and forget with no waiting (an Asyncify build would not be needed). Then you could use an IndexedDB VFS - perhaps just IDBBatchAtomicVFS patched to be read-only - for as many read-only connections as you wanted.
This wouldn't work transparently to the application - if multiple contexts need to write to the database then they would have to share a connection for write transactions - but it would allow concurrency that is nearly like Write-Ahead Logging (WAL) where database readers can query concurrently with other readers and one writer.
There are a couple reasons this wouldn't be quite as concurrent as WAL:
This isn't going to be worthwhile for most applications. One benchmarking attempt indicates that you probably need a fair amount of concurrency to reach the point where concurrent reads from multiple connections beats multiplexing reads on a shared but faster connection. Nevertheless, it is an interesting idea for the right workload, and maybe it could be a jumping-off point for other approaches.
Beta Was this translation helpful? Give feedback.
All reactions