Why a Workers Threads should load the WASM module into each Worker, isn't it could be shared for all Workers ? #20458
Replies: 3 comments 1 reply
-
The wasm module is shared between threads vis postMessage. But each thread needs to create its own instance of the wasm module. Is that what you are referring to? Wasm instances cannot currently be shared between Web Workers. This is limitation of the Web API. Very few things in fact can be shared between workers. As far as I know the only mutable thing that can be shared is SharedArrayBuffer. |
Beta Was this translation helpful? Give feedback.
-
Hi @sbc100 , look at the following steps that illustrate what I meant: Here is a simple c code:
let build it:
test.wasm size is 37KB Screenshot of the Console result is attached, the memory allocated is about 180MB ! Can you explain that behavior ? |
Beta Was this translation helpful? Give feedback.
-
Yes, you right - the memory indeed shared, and it seems that nothing to be done with the size of the WebWorker. |
Beta Was this translation helpful? Give feedback.
-
Is seems that Worker Thread duplicate the WASM Module for every Thread, isn't it could be shared for all Workers ?
Is Wasm Worker (instead of Pthread Worker) is also load the WASM Module ?
Beta Was this translation helpful? Give feedback.
All reactions