Closed hammadtq closed 6 months ago
Also from the source I could not understand if this adapter is written for all kinds of rayon threads like the ones I am using above or is it for specific use-cases.
No, it should work for any Rayon work, including rayon::spawn
.
But then, it completely depends on your program whether it's using all those threads efficiently. If each spawn
doesn't do much work and finishes quickly, it's entirely possible that execution will be still almost serial. It only makes sense to spawn off long-running, expensive tasks.
Until there's more information (e.g. clearly reproducible benchmark with expected vs actual behaviour), I don't think there's a bug here as those functions should work.
I am using rayon::scope and rayon::spawn in my wasm library with #[wasm_bindgen], I use
wasm-pack build --target web
to compile and my code structure is:I have used following js code to initialize number of threads through worker.js:
I am using M2 machine with 10 cores and I have tried entering cores manually as well. It compiles and loads, I can see multiple workerHelpers.js loading in the network tab along with my main wasm.js repeatedly. Seems like cores are being used but the end result is same benchmark time if I run it using single thread or multi-threards or don't use
wasm-bindgen-rayon
at all. Also from the source I could not understand if this adapter is written for all kinds of rayon threads like the ones I am using above or is it for specific use-cases.I will be grateful for any pointers.