An Adventure in Race Conditions

By Felix Petriconi

Chip speeds are not increasing, but the number of cores is, so the path to better performance is concurrency. But writing concurrent code is hard.

In this introduction to asynchronous programming, I’ll give you an outlook on high-level abstractions that will help you avoid the most common traps associated with locks and atomics.

I’ll use a series of code examples from our production to illustrate just how subtle race conditions can be. I’ll also share strategies that find these problems and better, avoid them in the first place and show that using high-level abstractions don’t result in performance loss.

The talk will cover the following topics:

  • Basic principles of code sharing in concurrent code

  • Mutability, mutex and locks

  • Atomics

  • Condition variables

  • Race conditions

  • Futures