Speedup

AdvancedAbout 12 minNetworks & systems, Programming & algorithms

One cook makes sandwiches for a party. Then three friends come to help. How much faster is it now?

One Cook, Four Cooks

You need 40 sandwiches, and each one takes a minute to make. On your own, that's 40 minutes.

Three friends turn up and you each make 10. Everyone works at the same time, so you're done in 10 minutes. Four cooks, four times as fast.

Computer scientists call that number — "how many times faster" — the speedup:

speedup = time with one workertime with many workers

Here, 40 ÷ 10 = a speedup of 4.

Doing Things at the Same Time

Working one step after another is called sequential work. Splitting a job so several workers do parts of it at the same moment is called parallel work. Computers do this too: most phones and laptops have several "cores" — separate little processors inside the same chip — that can each work on a different part of a job at once.

The Catch: Some Steps Can't Be Shared

Real kitchens aren't quite that simple. Before anyone starts, someone has to unpack the shopping and lay everything out (5 minutes). At the end, someone has to pack all the sandwiches into one cooler (5 minutes). Extra cooks don't make those steps any faster — it's still one person unpacking one bag.

  • 1 cook:50 min (5 unpacking + 40 making + 5 packing)
  • 2 cooks:30 min (5 unpacking + 20 making + 5 packing)
  • 4 cooks:20 min (5 unpacking + 10 making + 5 packing)
  • 8 cooks:15 min (5 unpacking + 5 making + 5 packing)
CooksTotal timeSpeedup
150 min1×
230 min1.67×
420 min2.5×
815 min3.33×

Four cooks now give a speedup of 50 ÷ 20 = 2.5, not 4. Doubling to eight cooks only gets you to about 3.3. The one-person steps take the same 10 minutes no matter how many cooks you add — so eventually, more help barely helps at all.

Adding workers only speeds up the parts of a job that can be shared. The parts that can't be shared set a limit on how fast the whole job can ever be.

Working It Out Like a Computer Scientist

Here's the kind of question you'll see in a computer science class. A computer has four tasks to run. None of them depend on each other:

  • Task A: 40 s
  • Task B: 30 s
  • Task C: 20 s
  • Task D: 10 s
  • One processor has to run them one after another: 40 + 30 + 20 + 10 =100 seconds.
  • Two processors can share them. A good split is A + D on one (50 s) and B + C on the other (50 s). Both finish at the same time: 50 seconds, a speedup of 100 ÷ 50 = 2.
  • A poor split — A + B on one (70 s) and C + D on the other (30 s) — takes 70 seconds, because you have to wait for the slowest processor to finish.

With parallel work, the total time is set by whichever worker finishes last. Put another way: total time = the parts that must be done one at a time + the longest of the shared parts.

Try It With Helpers

Want to see speedup happen? The Distributed Computing page lets you split a big counting job between as many helpers as you like and time the result.

Try it nextCrowdsourcing & Distributed Computing →

Check your understanding

5 quick questions. Pick one answer for each — you'll see why straight away.

  1. A job takes 60 seconds on one processor. Split across several processors, it takes 20 seconds. What is the speedup?

  2. Four tasks take 40, 30, 20 and 10 seconds. They're split across two processors: one runs the 40 and 10, the other runs the 30 and 20. How long does the whole job take?

  3. Why doesn't adding more and more workers keep making a job faster forever?

  4. A program has a 10-second part that must run on its own, plus 40 seconds of work that can be split evenly. How long does it take with 4 processors?

  5. Which job would gain the MOST from being split across many processors?