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.
Update
The "access handle pool" vfs has been forked out into this PR #130 , aiming to merge it.
This branch includes a couple experimental OPFS VFSs:
opfs-worker
This is a new custom VFS for OPFS, it uses a WebWorker with SharedArrayBuffers and Atomics to enable use of the async OPFS APIs. (Its not suing WASMFS as that would require a separate build)
It's currently a little slow as no care for optimisations have been taken.
On the to do list:
opfs-ahp
This is an "access handle pool" VFS inspired by the AHP SQLite VFSs.
Essentially it opens a large pool of sync access handles before Postgres startes, and uses them to create a VFS layered on top of OPFS.
Your datadir looks like:
state.jsonl
is a log file to maintain the tree of the VFS, each file underdata/
is mapped to a specific file in the VFS.The state file is a WAL, so it's quick to append to and rolls back if an operation fails. There is then a periodic checkpoint wher the state file is rewritten and compressed. (I suspect there is a race condition here currently as OPFS doesn't have an atomic rename/move, but solvable)
I call
.flush()
on the file handles for the Postgres WAL files if they are modified during a query to attempt some high durability.We already had a "relaxed durability mode" for the IDB VFS (its so slow to flush whole files), and so I've also added one to the OPFS AHP VFS - this just skips the flush of the Postgres WAL files and lets the OS schedule a flush. It's very very quick, only a touch slower then in-memory. I suspect for most embedded use cases this is absolutely suitable.