Building confidence in concurrent code with a model checker
summary
Demonstrates using TLA+ and the TLC model checker to find real concurrency bugs: a queue model with max size 2 checks 1 producer/1 consumer (8 states) and shows the producer/consumer with 2 producers 2 consumers fails invariant (38 states, counterexample trace where bounds are violated). Shows subtle stuttering/fairness issues when counting to three, models a zero‑downtime deployment, finds a downtime counterexample, and fixes it with a one‑at‑a‑time rule plus a load‑balancer model; checks succeed.
AI-written summary · about
chapters (43)
- 0:00Intro
- 1:01Why concurrent code in particular?
- 2:23Tools to improve confidence
- 3:34A good model is a tool for thinking
- 4:14What is "model checking"?
- 4:53Two popular model checkers
- 7:27Outline of this talk
- 8:00Here's a spec for a sort algorithm
- 9:11What is your confidence in the design of this sort algorith
- 9:59Some approaches to gain confidence • Careful inspection and code review
- 11:06A concurrent producer/consumer system
- 11:37A spec for a producer/consumer system Given a bounded queue of items And 1 producer, i consumer running concurrently
- 12:43What is your confidence in the design of this producerlconsume 28.6%
- 14:00What is your confidence in the design of this producer consumer
- 15:06How to gain confidence for concurrency?
- 17:34Boolean Logic
- 19:31States and transitions for a chess game
- 19:44States and transitions for deliveries
- 21:27Actions are not assignments. Actions are tests
- 24:31Count to three, refactored
- 27:29Updated "Count to three"
- 28:22What is the difference between these two systems!
- 29:16"Count to three" with stuttering
- 30:51Useful properties to check
- 32:11Properties for "count to three" In TLA
- 33:28Adding properties to the script
- 34:59If we run the model checker, how many of these proper
- 35:58Who forgot about stuttering?
- 37:40How to fix? Refactor #1: change the spec to merge init/next
- 39:19The complete spec with fairness
- 40:31Modeling a Producer/Consumer system
- 40:49States for a Producer
- 43:31States for a Consumer
- 44:13Complete TLA* script (2/2)
- 46:50And if we run this script?
- 47:33TLA plus... Set theory
- 52:21Fixing the error
- 53:39Using TLA* as a tool to improve design
- 54:18Modeling a zero-downtime deployment
- 56:30Stop and check
- 56:49Temporal properties
- 57:45Running the script
- 59:21Adding another condition New rule! All online servers must be running the same version
related talks
01h 07mBuilding confidence in concurrent code with a model checker
49mThinking in a Highly Concurrent, Mostly-functional Language
38mAccidentally Concurrent
22mConcurrency Models Demystified
58mDesign and Implementation of Highly Scalable Quantifiable Data Structures in C++
42mHistory of Concurrency
55mBehavioral Modeling in HW/SW Co-design Using C++ Coroutines
55mC++ Concurrency TS 2 Use Cases and Future Direction
