emscripten-core / emscripten-core/emscripten

WASMFS (with OPFS backend) is extremely slow when reading simultaneously from multiple threads

Open
#27,134 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

Please include the following in your bug report:

**Version of emscripten/emsdk:**
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 4.0.19 (08e2de1031913e4ba7963b1c56f35f036a7d4d56)
clang version 22.0.0git (https:/github.com/llvm/llvm-project 12f392cff10fcc70b4ec4f01ab386922742e9136)
Target: wasm32-unknown-emscripten
Thread model: posix

**Description:**
When reading multiple chunks from multiple threads from one given big file (seek & read), using WASMFS is like 10 times slower than IDBFS.
My understanding of the problem is that, behind the scenes, all WASMFS/OPFS access are queued to one single web worker, where with IDBFS the readings can actually occur in parrallel, the file being in memory.
IDBFS allows a "real" parrallel access to the file system, but it should not be used for big files because the files are in memory.
WASMFS does not load the entire file in memory but uses a lock / queue mechanism which drastically impact the performance when doing massive parrallel reads.
Is my understanding right ? How can I workaround this, or what file system is recommanded for an efficient parallel reading ?

Thanks

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with emcc 4.0.19 using one large file and simultaneous seek/read calls from multiple threads, comparing WASMFS with the OPFS backend against IDBFS. Trace whether OPFS requests are serialized through one worker or lock, then document a confirmed workaround or recommended filesystem for efficient parallel reads.

Written by the indexing model from the issue text.

Assessment

Tech stack
wasm
Domain
operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.