Now we have crammed in how parallelism is done in Haskell and an overview of the threaded runtime. We parallelized pure and lazy data structures with strategies and Eval
(the parallel
package). For more control and parallelism in IO, we had to resort to schedules and Par (the monad-par
package). We dived into data-parallel programming with Repa and even wrote a string recognition program with it.
We learned to use the event log and ThreadScope to diagnose the parallel performance of Haskell programs. Things to keep in mind when parallelizing programs are: use good granularity, not too much overhead but not too much sequential processing either; compile with flags optimized for parallelism, especially with Repa; and profile and diagnose before applying transformations at the code level.
In the next chapter, we will look at stream processing in Haskell: I/O, networking, and streaming libraries such as conduits and pipes. Lazy I/O, combined with interacting with networks, produces nightmarish...