Replies: 3 comments 25 replies
-
I think this proposal is necessary in the broad strokes. I don't think there's a strong non-determinism argument against this proposal as we already have shared memories and Web workers. One thought (which I'd be happy to spin out into a separate issue): one argument that may come up against this proposal is that in the wider Web platform community, APIs and language features are generally prohibited from observably carrying out/creating concurrent execution - Web workers are considered specially blessed to do this. In theory, a minimal Wasm proposal could work with just |
Beta Was this translation helpful? Give feedback.
-
I am very much in favor of the I am less certain about an actual instruction to spawn a thread, because while a pure-wasm thread could be lighter-weight than a Web Worker today, we actually need the heavyweight JS parts, since that JS is the only API surface the wasm has. It is very common for threads to do things like:
All those require a JS environment. Concretely, if we think this makes sense on the Web then we'd need to have a plan for how such lightweight threads access APIs. I don't have a good idea myself there. One option is proxying their requests to another thread to access JS for them. This was actually how PNaCl worked, and it had large downsides - asm.js and then wasm improved on that by allowing direct synchronous access to Web APIs. Emscripten does have such a proxying mechanism that we can use (we use it today to proxy to the main thread for things that only work there, and other things), and it is heavily optimized, but it is still slow. In fact, we are doing a lot of engineering to reduce the amount of proxying that we do (e.g. in the WasmFS project). Overall, I think proxying is not promising, but maybe there are other ideas. |
Beta Was this translation helpful? Give feedback.
-
Three points from my perspective:
That said, I agree that this can be separated from adding sharability to the type system. How fine-grained we make proposals is a question of considerable administrative overhead, however. |
Beta Was this translation helpful? Give feedback.
-
Not everyone may believe that a separate WebAssembly proposal for spawning threads is a good idea. Perhaps the status quo is sufficient or other concerns (e.g., non-determinism) are more important. Others may be convinced that this is necessary. I'm opening this discussion to hear both sides of this question ‐ is this proposal necessary?
Beta Was this translation helpful? Give feedback.
All reactions