Open Bug 1713066 Opened 3 years ago Updated 10 months ago

Compile bergamot-translator's WASM module with threads support

Categories

(Firefox :: Translations, enhancement)

enhancement

Tracking

()

People

(Reporter: anatal, Unassigned)

References

(Blocks 1 open bug)

Details

We would like to experiment with threads since there's some evidence it can fasten the translations. I remember hearing that the Wasm working group had support for pthreads in the roadmap, but I don't have the most current info. :lars, could you please help here?

Flags: needinfo?(lhansen)

Some kind of "direct" pthreads support is not even on the drawing board in the wasm CG, and once it exists it might in any case be a poor fit for the web if used naively, since the main thread of a web agent is distinguished and is not allowed to block - only non-main threads can block, unlike for real pthreads.

For the foreseeable future (literally years), web workers + SharedArrayBuffer are going to be the only option for wasm threads on the web.

There is some pthreads simulation support in emscripten (on top of web workers). I don't know how good it is or how well it fits into eg extensions, ni'ing Yury for a more informed opinion on that.

Each web worker has significant startup time and memory overhead, so maintaining a pool of these and farming out work to them is almost certainly going to be necessary for a good experience, as opposed to starting and terminating them. I don't know if emscripten maintains a pool, though I would expect it to.

Whether it's best to go with emscripten's solution here, whatever it is, or to create our own custom abstraction of a worker pool, I don't know. If we move from using emscripten to using wasi/llvm for the compiler toolchain we may need to do the latter.

Flags: needinfo?(lhansen) → needinfo?(ydelendik)
Flags: needinfo?(ydelendik)
Type: defect → enhancement

André is this still valid?

Flags: needinfo?(anatal)

Yes. Bergamot-translator is still single threaded.

Flags: needinfo?(anatal)
You need to log in before you can comment on or make changes to this bug.