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.
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 pages | Level by level | wait(FIRST_COMPLETED) |
|---|---|---|
| 1, on level 1 | 0.68 s | 0.68 s |
| 2, on levels 1 and 2 | 1.13 s | 0.69 s |
| 3, one on each level | 1.58 s | 0.69 s |
Each level pays for its own slowest page. The growing set of pending futures pays once.
Workers never wait on other futures
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