Debugging, Testing, and Performance
Finishing your concurrent code is not the finish line — you still have to confirm that it is both correct and fast. Concurrency bugs have a particularly insidious quality: they may run flawlessly ten thousand times on your dev machine, then blow up in production every few days. And under concurrency, "good performance" becomes an engineering question that demands scientific measurement, not something you settle by gut feeling.
In this chapter we tackle two ultimate questions: first, how to use tooling to systematically detect and diagnose concurrency bugs (data races, deadlocks, livelocks, dangling references); second, how to scientifically measure the performance of a concurrent program, steering clear of the many traps that benchmarks lay for you.