Book review: Is parallel programming hard, and, if so, what can you do about it?
A developer reviews Paul McKenney's classic concurrency textbook, detailing how CPU cache mechanics and compiler optimizations make parallel programming uniquely difficult.
summary is enough The review offers an entertaining personal perspective on learning low-level concurrency, though the key takeaways fit comfortably in a summary.
summary
The author reflects on reading Paul E. McKenney's free online concurrency textbook during a rural vacation, noting how it dismantled their distributed systems assumptions. They explore eye-opening chapters on hardware cache coherency and hazardous compiler optimizations that threaten parallel code correctness. While praising the book's depth on topics like per-thread counters, the author eventually moved on to specialized lock-free data structure texts.
key points
- CPU cache protocols like MESI ensure cores must contend for exclusive cacheline ownership before writing, disproving intuitive notions of simultaneous writes.
- Aggressive compiler optimizations such as load/store tearing and code reordering introduce severe hazards into unsafely written parallel code.
- Alternative textbooks like Herlihy and Shavit's Multiprocessor Programming are frequently recommended by commenters for tackling lock-free structures.
who should read it
Systems programmers and software engineers exploring low-level concurrency and hardware-software interaction.
discussion positive
consensus
Commenters widely agree that parallel programming and debugging race conditions are excruciatingly difficult, often feeling like chasing ghosts.
pushback
A sub-thread debated whether a rigid semantic distinction between concurrency and parallelism is useful or merely pedantic.
I would probably recommend the art of multiprocessor programming (herlihy and shavitz) as a good starting point for concurrent programming. There is also " A primer on memory consistency and cache coherence" (Nagarajan et al) if you want to get more into the interaction between memory consistency and coherence.
Provides concrete alternative textbook recommendations for readers looking to dive deeper into multiprocessor programming and memory consistency.
Generated by an LLM from the article and thread. Check the sources before relying on it.