Repository navigation
Make memvfs shareable between threads behind a threadsafe feature - #204
LucaCappelletti94 wants to merge 2 commits into
Conversation
39e3150 to
e8e0fd7
Compare
|
Thanks for the PR. But how does it work correctly on wasm? With |
Oh, I see. However, I'm curious whether it's possible to have a proper mutex implementation. Did you use futex-based mutexes or no-op mutexes in your tests? |
Futex-based, never no-op. The native tests here use For Wasm, the follow-up PR adds a futex-style mutex on I will open the stacked PR shortly so you can have a look, I have been trying to find either some seams or possible cleanups to make it smaller as for now it is ~1k lines. |
e8e0fd7 to
2172557
Compare
Part of #202. Stacked on #205, so only 2172557 is added here.
memvfs keeps real SQLite lock levels per file, following the unix VFS, so connections sharing a database get
SQLITE_BUSYon conflict. Two connections to one memvfs database used to share pages without any locking, which the docs called unsupported. This is the only change for builds withoutthreadsafe.With
threadsafe, which now also turns onrsqlite-vfs/threadsafe, the file map and every file are guarded bySQLITE_MUTEX_FASTmutexes from SQLite's mutex API and shared throughArc, so those connections may live on different workers.installthen requires theOsCallbackto beSend + Sync, expressed by a newMemVfsOstrait that everyOsCallback + 'staticsatisfies without the feature. The last VFS error becomes per thread, sincexGetLastErrornames no connection, which pulls instd.