2017-08-18 15:50 GMT+03:00  <ilia.galas...@gmail.com>:
> Hello,
> I tried to use several web worker in my project and noticed that when we
> have more than one worker at the same time, they do not perform operations
> in parallel mode.

Web workers should run in parallel as long as you have enough physical
cores available to host them. Though launching web workers is not
parallel, and any postmessaging that are needed to synchronize can
limit parallelism.

> Looks like they do operations step by step.
> I compile code to WASM and run worker form C++ code with
> emscripten_create_worker command.
> For instance, one worker can complete operation, but I get callback only
> when second worker is finished.

How long do the operations take? Are these several seconds, or
milliseconds apart? If the computation is not too long, the initial
startup time can outweight the computation time.

I would recommend not using emscripten_create_worker in a hot path,
but instead do the computation via emscripten_call_worker, and create
the workers at startup time. Creating workers is slow, but calling
functions on them is much faster, so preloading the workers can help.

> When I use five or six workers my UI is ok, but analyzing time I assume that
> operations do not execute during the same time.
> I want to use at the same time from 5 to 50 web workers and execute
> operations in parallel mode and analyze callbacks when some worker is ready.
> Is there any way to do this ?

> Also emscripten_create_worker command ususally takes from one to two
> seconds, but when I create other workers it takes from 0.1 to 0.2 seconds.

Worker startup time depends on the amount of code you load in the
worker. This sounds like you are not comparing apples to apples, but
starting up Emscripten-compiled .js/.asm.js/.wasm files to smaller
handwritten workers? To optimize worker startup time, try making the
code as small as possible, or move worker startup to "cold time", as
suggested above.

-- 
You received this message because you are subscribed to the Google Groups 
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to emscripten-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to