Magpie

A work-stealing thread pool, written from scratch in C.

GitHub ↗

Threads are normally invisible. This makes them watchable. Eight worker threads render a Mandelbrot fractal, one tile per task. The interior is slow and the empty space is fast, so the work is lopsided, and when a thread runs out of its own tiles it steals from a busy one instead of standing idle.

Everything below is a real run recorded by the C program. The schedule, the steals, and the timings are exactly what happened; the playback is slowed down so you can see it, and the fractal image is the same math recomputed in your browser.

0 / 256 tiles 0 steals 0 threads working t = 0.0 ms
The image fills in tile by tile, each briefly tinted by the thread that drew it.
Each row is one thread's timeline. Bars are tasks; a steal is marked with an arrow from the thread it was taken from. The line is “now.”

Does adding threads actually help?

Speedup over a single thread, measured on the same fractal. It climbs, then flattens once the work outruns the cores, the diminishing returns of Amdahl's law, measured rather than assumed.