15/28
Part 4 of 6 · A pool and a coordinatorLearn and do

Level by level, every level waits for its slowest page

Here is what that waiting costs, on a site with a few slow pages.

25 pages, 3 of them slow, 8 workers
level by level
1.58 s
wait(FIRST_COMPLETED)
0.69 s

Level by level, a level starts only when the one before is done. With FIRST_COMPLETED, each chain moves on by itself.

The site is a home page linking 8 pages, and each of those starts a chain of two more. A few pages sleep 0.5 s instead of 50 ms, each on its own chain. With 8 workers:

Slow pagesLevel by levelwait(FIRST_COMPLETED)
1, on level 10.68 s0.68 s
2, on levels 1 and 21.13 s0.69 s
3, one on each level1.58 s0.69 s

Each level pays for its own slowest page. The growing set of pending futures pays once.

Workers never wait on other futures

Predict

Each worker fetches a page, submits its links and calls .result() on them. 4 workers, a chain of 11 pages. What happens?

Pick an answer above to see the rest