You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In addition to the traditional POSIX APIs, some applications would benefit from having asynchronous file system APIs as well. Perhaps there could be default implementations that just call the synchronous version of the API and immediately call the user callback, the specific backends could specialize that default as appropriate.
Reacted by Rémi Bardon, Jack Wasey, Dennys Rojas and John-Henry Lim
I need it so much! 🥇
Using the asynchronous interface, can directly call the file system in web worker and main thread without blocking and unnecessary thread(sync thread) overhead.
Is this still planned? Our codebase uses POSIX async IO (aio) where available, but the web version currently needs a fallback using fopen (with directories mapped using wasmfs_create_directory and an opfs backend).
Would be amazing to unblock native workers that request files (and later on write too, but that's not too important for us right now).
P.S. I know that musl supports aio, but I assume this is stripped out of emscripten on purpose due to not being implemented? @sbc100 I see you've been updating it recently, do you know the procedure?
Yup I can see that, luckily we don't use aio_suspend ourselves.
Looking at the opfs implementation we could probably switch over to the native wasm_fs API later on instead of aio. From first glance _wasmfs_opfs_read_blob would be enough for us, blocker seems to be that we don't have access to the wasmfs worker thread / proxy context. Might give exposing some minimal read-only async API a go at some point.
This is a blocker for supporting large local sites and multiple PHP web workers in WordPress Playground.
We support synchronizing data between MEMFS and a DirectoryHandle. However, lacking a pthreads build of WebAssembly limits what we can do with the filesystem. We don't have a good way of:
Synchronizing MEMFS between workers
Synchronizing concurrent writes to a local FileSystemFileHandle between workers
Stream-reading large files from a local FileSystemFileHandle without loading them into memory
With an asynchronous filesystem, we could mount a FileSystemDirectoryHandle at, say, /wordpress, and directly interact either with OPFS or with the local filesystem.
I was looking for a way to use OPFS mounts for a while, but couldn't find any resources. I also couldn't figure that out from the wasmfs_opfs.c link that often gets passed around as an example.
Activity
medns commentedon Sep 22, 2023
I need it so much! 🥇
Using the asynchronous interface, can directly call the file system in web worker and main thread without blocking and unnecessary thread(sync thread) overhead.
ifiddynine commentedon May 29, 2024
Is this still planned? Our codebase uses POSIX async IO (aio) where available, but the web version currently needs a fallback using
fopen(with directories mapped using wasmfs_create_directory and an opfs backend).Would be amazing to unblock native workers that request files (and later on write too, but that's not too important for us right now).
P.S. I know that musl supports aio, but I assume this is stripped out of emscripten on purpose due to not being implemented? @sbc100 I see you've been updating it recently, do you know the procedure?
sbc100 commentedon May 29, 2024
I imagine it would be a fair amount of work to implement aio. In particular
aio_suspendwould require something likeASYNCIFYin order to work.ifiddynine commentedon May 29, 2024
Yup I can see that, luckily we don't use aio_suspend ourselves.
Looking at the opfs implementation we could probably switch over to the native wasm_fs API later on instead of aio. From first glance
_wasmfs_opfs_read_blobwould be enough for us, blocker seems to be that we don't have access to the wasmfs worker thread / proxy context. Might give exposing some minimal read-only async API a go at some point.adamziel commentedon Aug 2, 2024
This is a blocker for supporting large local sites and multiple PHP web workers in WordPress Playground.
We support synchronizing data between MEMFS and a DirectoryHandle. However, lacking a pthreads build of WebAssembly limits what we can do with the filesystem. We don't have a good way of:
With an asynchronous filesystem, we could mount a
FileSystemDirectoryHandleat, say,/wordpress, and directly interact either with OPFS or with the local filesystem.I was looking for a way to use OPFS mounts for a while, but couldn't find any resources. I also couldn't figure that out from the wasmfs_opfs.c link that often gets passed around as an example.