nitish24p/react-worker-image

Is spawning a new worker for every image a good idea?

Opened this issue · 9 comments

See title. I don't really have experience with those, but shouldn't be one worker sufficient? I imagine loading 50+ images via 50 workers is slower than loading 50 images with 1 worker

Yes this had come up into my head. Browsers offer support for using shared workers instances, so can try that or can terminate the worker once the inage has been downloaded.

@manjula91 thoughts..

I'll ask Benedikt Meurer on Twitter, he's a v8 performance engineer. https://twitter.com/kurtextrem/status/962234931400335367

I'd guess when we spawn more than OS CPU cores - 1 (as one core is used already by the main thread), we probably have no benefits or a negative impact. But let's find out, I'm curious as well :)

shared workers can be given a shot here

@kurtextrem Lets find out how impact full it will in this case?

What would be the difference in our case between those two? The only difference I can see is "[Shared Workers can be] accessed from several browsing contexts, such as several windows, iframes or even workers"
I think we should continue using Web Workers, especially as Apple / Safari dropped Shared Workers support, and instead of spawning them in each component, we should spawn them outside or in a factory that decides whether enough have been spawned or not.

Fair enough i think that sounds great. Would you want to take this up @kurtextrem ?

@manjula91 I'd like to wait for Benedikt's opinion first, but I'd love to do this for sure afterwards! :)

cool 👍