react-worker-image icon indicating copy to clipboard operation
react-worker-image copied to clipboard

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

Open kurtextrem opened this issue 7 years ago • 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

kurtextrem avatar Feb 09 '18 22:02 kurtextrem

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.

nitish24p avatar Feb 10 '18 05:02 nitish24p

@manjula91 thoughts..

nitish24p avatar Feb 10 '18 06:02 nitish24p

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 :)

kurtextrem avatar Feb 10 '18 07:02 kurtextrem

shared workers can be given a shot here

manjula-dube avatar Feb 10 '18 08:02 manjula-dube

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

manjula-dube avatar Feb 10 '18 08:02 manjula-dube

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.

kurtextrem avatar Feb 10 '18 08:02 kurtextrem

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

manjula-dube avatar Feb 10 '18 08:02 manjula-dube

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

kurtextrem avatar Feb 10 '18 08:02 kurtextrem

cool 👍

manjula-dube avatar Feb 10 '18 09:02 manjula-dube