Your laptop has multiple cores. When you run a parallel program, something has to decide which core runs which piece of work — and doing that badly wastes hardware you already paid for.
The naive answer is to hand out tasks in advance: split the problem into equal chunks and give one chunk to each core. But tasks rarely finish at the same time. One core may be done in a millisecond while another is still grinding through its chunk. The idle core just sits there.
Work-stealing fixes this with one elegant rule: whenever a core runs out of tasks, it steals a task from the back of another core's queue. No central coordinator, no global lock — each core manages its own local deque and only reaches out when it has nothing left to do.
The result is near-perfect load balance with almost no overhead. It was formalized by Robert Blumofe and Charles Leiserson in 1999, and it now powers scheduling runtimes from Cilk and Java's ForkJoinPool to Rust's Rayon and Go's goroutine scheduler.
Comments
Loading comments...