Five Seconds That Will Not Divide Cap a Thousand Workers at Twenty Times
Last timeTime for One, Rate for All
Some work divides among workers and some cannot. The part that cannot sets a ceiling on any number of workers, and slow workers reach that ceiling from a worse start.
Does it split
The first two lessons used jobs at the two extremes: items with nothing to do with each other, and a chain where every step needs the one before. A real job is a mixture, and the first skill is sorting it into the two kinds.
The test is one question asked of each piece. Does it need a result that some other piece is still producing? If no piece does, the pieces are independent and any number of workers can hold one each. Reading the same inputs does not count. Two workers can read one array all day. What forces an order is one worker waiting for another's answer.
| step | computation | what one piece needs | does it split | what happened |
|---|---|---|---|---|
| 1 | brighten every pixel of an image | its own pixel and nothing else | yes, one piece per pixel | No pixel's new value depends on another's. This is the shape a GPU was first built for. |
| 2 | add up an array | its own slice of the array | yes, apart from a short joining step | Each worker totals a slice. The partial totals then have to be added together, and that join is work that does not divide evenly. |
| 3 | a running total, element by element | the running total just before it | no, as written | Each output is the previous output plus one element. Written this way it is a chain. |
| 4 | a simulation over many time steps | the whole state after the step before | inside a step yes, across steps no | A mixture. The cells of one step can be updated side by side, and the steps themselves stay in order. |
| 5 | read the input file and set up | the file, in order | no | Nearly every job begins and ends with something like this. |
The part that will not divide
Take a job that is 100 seconds of work for one plain worker. Reading it with the test above shows that 5 seconds of it will not divide and 95 seconds will.
- seconds until the job is finished
- seconds of work that will not divide
- seconds of work that divides
- number of workers, each of speed 1
On sixteen workers that is seconds, about 9.1 times faster than one worker. On 1,024 workers it is seconds, 19.6 times faster. Sixty-four times the workers bought barely twice the speed, and the second term is now under a tenth of a second.
The lesson stops here
4 more paragraphs to go
You have read the opening. The rest of the argument, the problems that check whether it landed, and the lines worth keeping at the end all come with a plan.
The first lesson of every course in the library reads the whole way through, free, so you can see exactly what the rest of them are.
See the planThe contentsThis is the reading half
Starting the course gives you your own copy of it. Every idea on every page has problems standing under it, marked with a reason rather than a tick, and any sentence you do not believe can be opened and argued with. None of that can happen on a page nobody owns.
The contents