liveBook · Manning

Work stealing

As explained in Learn Haskell by Example

Work stealing is a scheduling technique in which an idle execution worker takes available work from a shared pool.

Work stealing schedules parallel work by letting an idle Haskell execution context take a spark from a shared spark pool and evaluate it. section 13.4.3

The runtime handles the main scheduling details:

  • rpar places a computation, represented by a spark, into the spark pool without waiting for it to finish. section 13.4.3
  • An available Haskell execution context steals a spark and evaluates its underlying thunk in parallel. section 13.4.3
  • Sparks can become duds, fizzle, overflow, or be garbage collected; the runtime manages these cases. section 13.4.3

Parallel list evaluation

Control.Parallel.Strategies can apply rpar across a list with evalList, while withStrategy starts the chosen evaluation strategy. Chunking work reduces excessive spark creation for large vectors.

Figure 13.5 Haskell execution contexts and spark pools
figure

A figure showing Haskell execution contexts taking sparks from shared spark pools. section 13.4.3

How Learn Haskell by Example covers it

How deep it goes
Explains spark pools, execution contexts, and failure states, while deferring scheduling internals to the runtime.
Examples
Uses parallel list mapping, pixel-vector processing, chunked execution, and runtime spark statistics.
What it assumes
Assumes familiarity with Haskell computations and introduces sparks, thunks, execution contexts, and evaluation strategies.
What you can do after
Apply it via Control.Parallel.Strategies to parallelize list or vector computations and inspect spark behavior.
How it connects
Connects sparks, thunks, Haskell execution contexts, spark pools, rpar, rseq, and parallel evaluation strategies.

Also explained in

Compare how 5 books explain work stealing →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Haskell by Example. The section links point to the parts of the book it draws on.