Abstract
Lock-free concurrent algorithms guarantee that at least one concurrent operation will make progress in a finite number of steps. However, programmers often prefer the stronger guarantee of wait-freedom, where every operation is guaranteed to complete. While wait-free algorithms are theoretically superior, they are notoriously complex and often inefficient in practice, leading most commercial implementations to rely on lock-free designs. This paper bridges the gap between these two progress conditions. By analyzing a general class of lock-free algorithms under a stochastic scheduler—which more closely approximates real-world hardware than the traditional worst-case adversary—we demonstrate that lock-free algorithms behave as if they are wait-free. Using a Markov chain lifting technique, we prove that these algorithms are not only wait-free with probability 1 but also provide tight bounds on the expected number of steps required for operation completion.
Introduction
In multicore computing, the choice between lock-free and wait-free progress properties is a fundamental design trade-off. A lock-free algorithm ensures that the system as a whole makes progress, but it theoretically allows an individual process to be starved indefinitely by a malicious scheduler. A wait-free algorithm guarantees that every process finishes its operation in a finite number of steps, providing a robust fairness guarantee.
Despite the theoretical appeal of wait-freedom, the "gold standard" is rarely used in production. Wait-free algorithms often require complex "helping" mechanisms where processes assist each other to ensure progress, leading to significant performance overhead. Consequently, practitioners favor simpler lock-free structures. This paper addresses the central mystery of this preference: Why don't lock-free algorithms starve in practice? The authors argue that the discrepancy exists because traditional theoretical models assume a "worst-case adversary" scheduler. In reality, hardware schedulers are not malicious; they are stochastic.
The Stochastic Scheduler and SCU Algorithms
The researchers replace the adversarial model with a Stochastic Scheduler. In this model, the scheduler selects a process to execute based on a probability distribution (e.g., a uniform $1/n$ chance for each of $n$ processes). This shift reflects the inherent randomness and jitter found in modern hardware architectures.
To analyze this, the paper focuses on Single Compare-and-Swap Universal (SCU) algorithms. This class encompasses many common lock-free data structures, such as stacks, queues, and hash tables. An SCU operation typically follows a three-step pattern:
- Preamble: Perform local computation.
- Scan: Observe the current state of the shared data structure.
- Validate/CAS: Attempt to update the state using an atomic Compare-and-Swap (CAS). If the state has changed since the scan, the CAS fails, and the process must retry.
Theoretical Framework: Markov Chain Lifting
The core mathematical contribution is a technique called Markov Chain Lifting. Analyzing a system with $n$ concurrent processes is traditionally difficult due to the high-dimensional state space. The authors simplify this by "lifting" the complex per-process Markov chain into a simpler "system progress" chain.
By modeling the contention as an iterated balls-into-bins game, they bound the number of steps required for a process to successfully land a CAS. This analysis reveals that starvation is statistically impossible under a stochastic scheduler; the precision required for a scheduler to indefinitely block a process is destroyed by the random nature of the execution.
Key Insights and Results
The $\sqrt{n}$ Contention Factor
One of the paper's most significant findings is that system latency for SCU algorithms scales with $O(\sqrt{n})$ rather than linearly with $n$. This is a result of the "birthday paradox" effect: as more processes (balls) attempt to access the data structure (bins), the probability of a successful update increases non-linearly. Specifically, for an algorithm with a preamble of length $q$ and a scan of length $s$, the expected system latency is $O(q + s\sqrt{n})$.
Individual vs. System Latency
The authors prove a fundamental fairness property: in the long run, the time an individual process takes to complete an operation is exactly $n$ times the time the system takes to complete any operation. The expected steps for a specific process to finish is bounded by $O(n(q + s\sqrt{n}))$.
Empirical Validation
While the paper is primarily theoretical, the authors validated their model using an 80-thread Fujitsu PRIMERGY server. By measuring the execution of a lock-free fetch-and-increment counter, they found that the actual completion rates closely matched their predicted $\Theta(1/\sqrt{n})$ curve. This significantly outperformed the $1/n$ prediction derived from worst-case analysis, confirming that stochastic models are a superior tool for predicting real-world performance.
Conclusion
This research provides a mathematical justification for the industry's reliance on lock-free algorithms. By demonstrating that lock-freedom effectively implies wait-freedom under realistic scheduling conditions, the authors allow programmers to continue designing simpler, more efficient lock-free structures without fearing the theoretical risk of starvation. This work marks a vital step in aligning concurrent programming theory with the practical realities of modern multicore hardware.
Summary updated