You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Question: What is the expected speed up when the communication is minimal? #124
Suppose you have a CPU bound task: "Count how many times you can calculate the square root in 10 secs"
When I tried a serial implementation, it was faster than 2 workers, 3 workers, 4 workers of doing the same task. Did not try with more workers.
Is this expected? I supposed I would see a linear speed up since these works do not send a message until the 10secs pass so I expected almost 0 overhead.
I have a 12500H CPU with 4P Cores 8E Cores and Total Threads 16.
Also I did not have more apps working that could push the system to its limits.
I do not understand. Why the following has terrible speed up on 2 workers. 2 workers were slower than the serial operation.
functiontimedCalculation(){consttargetTime=10000;conststart=Date.now();letsum=0;letoperations=0;// Busy loop until target time has passedwhile(Date.now()-start<targetTime){++operations;// Do some meaningless math to keep the CPU busysum+=Math.sqrt(Math.random()*1000);}returnoperations;}
// worker.mjsexportdefaultfunctiontimedCalculation(){consttargetTime=10_000conststart=Date.now()letsum=0letoperations=0// Busy loop until target time has passedwhile(Date.now()-start<targetTime){++operations// Do some meaningless math to keep the CPU busysum+=Math.sqrt(Math.random()*1000)}returnoperations}
Activity
AriPerkkio commentedon Sep 27, 2025
It depends. Ideally
<cpu-core-count> xtimes faster.On CPU with single core, yes.
If each worker runs for 10 seconds, it will still take 10 second.
Ghostblad3 commentedon Sep 27, 2025
I have a 12500H CPU with 4P Cores 8E Cores and Total Threads 16.
Also I did not have more apps working that could push the system to its limits.
I do not understand. Why the following has terrible speed up on 2 workers. 2 workers were slower than the serial operation.
AriPerkkio commentedon Sep 28, 2025
Can you show the full example? I'm seeing different results with following:
So main did
25_238_502, workers did124_733_933.