When will WebAssembly get real threads, not just shared memory between processes? I've seen articles from years ago talking about it as a future feature. Current status?
When will WebAssembly get real threads, not just shared memory between processes? I've seen articles from years ago talking about it as a future feature. Current status?
https://github.com/webassembly/threads
"This proposal adds a new shared linear memory type and some new operations for atomic memory access. The responsibility of creating and joining threads is deferred to the embedder."
As for the current status, it is listed on the proposals page: https://github.com/WebAssembly/proposals
The "Threads" proposal is in "Phase 3 - Implementation Phase" which means it's starting to be implemented, but it hasn't reached "Phase 4 - Standardize the Feature" where 2+ browsers implement it. The final stage would be "Phase 5 - The Feature is Standardized. See https://github.com/WebAssembly/meetings/blob/main/process/ph...
https://github.com/WebAssembly/threads/blob/main/proposals/t...
Atomics are well covered. The "wait" and "notify" primitives map efficiently to mutexes.
"Blocking on the main thread is not allowed, so we can't call lockMutex."
The main thread is special in WebAssembly land. Is it still the only one that can do graphics?
Also, I imagine that web assembly is a bytecode format and that should be _less_ susceptible to spectre.
Can you expand? This seems wrong to me.
Edit: read some papers, I'll be damned, it can. I don't understand how tho'. Would love to try playing with a POC that does that.
The entire notion of processes and threads is a bit weird inside of a WASM module. Arguably a WASM module shouldn't care about them at all - the host runtime should be managing parallelism.
(Or, I suppose it can just completely isolate the memory between threads, and say nothing is shared. But I don't think that's what people would want?)
> Support for built-in GC set to ship in Q4 2023
> Each Erlang process has its own stack and heap which are allocated in the same memory block and grow towards each other. When the stack and the heap meet, the garbage collector is triggered and memory is reclaimed. If not enough memory was reclaimed, the heap will grow.
That said, there is a WebAssembly compiler for Erlang:
What else am I missing?
[1] The Go compiler inserts yield calls (preemption opportunities) at various points in the emitted code, such as at function invocations and within loops.
You could spawn a Web Workers for each core, in theory, although some browsers will lie about the number of cores.
Right. The goal for games is to get more CPUs working on the problem.
You also now have fun thread affinity problems, like if you call setTimeout your timer IDs now have thread affinity, which is nonsense.