Towards Reduced Instruction Sets for Synchronization
Abstract
For decades, the design of concurrent data structures has been guided by the belief that "strong" synchronization primitives, such as compare-and-swap (CAS), are essential for high performance and linearizability. This paper challenges that paradigm by demonstrating that a combination of "weaker" instructions—specifically read, xor, decrement, and fetch-and-increment—can be used to build a lock-free Log object that performs as well as its CAS-based counterparts on modern X86 hardware. Our findings suggest that the hardware requirements for universal synchronization may be simpler than previously assumed.
Introduction
In concurrent computing, the coordination of multiple processes updating shared data is a fundamental challenge. Herlihy’s Consensus Hierarchy has long served as the standard for ranking the "power" of hardware instructions based on their ability to solve consensus. In this hierarchy, compare-and-swap (CAS) is considered a "strong" primitive because it can solve consensus for an arbitrary number of processes. Conversely, instructions like fetch-and-increment are labeled "weak," as they are theoretically limited to solving consensus for only two processes.
Consequently, the vast majority of modern, high-performance concurrent data structures are built using CAS. However, recent theoretical advancements suggest that applying combinations of different "weak" instructions to the same memory location might provide more synchronization power than any single instruction in isolation. This paper bridges the gap between theory and practice, investigating whether CAS can be replaced by a smaller, weaker set of instructions without sacrificing performance.
Methodology: The Concurrent Log
The authors design a linearizable Log data structure (or History object) to serve as a proof-of-concept. This object supports two primary operations: append(item), which adds an item to the log, and get-log(), which returns all items in their correct linear order.
Instruction Mixing
The core innovation lies in "instruction mixing"—the strategic use of different atomic operations on the same memory locations to achieve synchronization. The algorithm proceeds as follows:
- Global Indexing: A
fetch-and-incrementinstruction on a global counter $C$ assigns each process a tentative index in an array $A$. - Atomic Writing: A process attempts to record its item using an atomic
xoroperation. - Invalidation: To maintain log order and ensure slots are properly closed, the algorithm utilizes a
decrementinstruction. - Contention Management: To distinguish between successful writes and concurrent interference, the least significant bits of each array entry are reserved as "contention bits."
As shown in Figure 1, the memory word is partitioned. The $m$ contention bits allow the system to detect if a xor or decrement has occurred, effectively creating a race where only one operation "wins" in a manner that subsequent read operations can interpret. This design ensures that readers are wait-free, while writers remain lock-free.
Evaluation and Results
The implementation was evaluated on a modern X86 processor system using a synthetic benchmark with 32 concurrent threads. The workload was designed to test the throughput and latency of the Log object under high contention.
The results demonstrate performance parity: the algorithm built with "weak" instructions performed identically to a standard CAS-based implementation. This suggests that on current architectures, there is no "speed tax" for avoiding CAS. Furthermore, the authors noted that the instruction set could be simplified even further; both fetch-and-increment and decrement can be replaced by a single fetch-and-add instruction.
Discussion and Conclusion
The primary insight of this work is that the traditional Consensus Hierarchy may be overly restrictive by treating instructions as if they are applied to distinct objects. By allowing different types of atomic instructions to "cross-pollinate" on the same memory location, developers can unlock synchronization power that exceeds the theoretical limits of individual primitives.
While performance is currently equal on X86 chips, this balance might shift in future architectures, such as Processing-in-Memory (PIM), where the internal logic of memory chips might favor specific instruction types. This research opens the door to a fundamental question: What is the absolute minimal set of synchronization instructions required for hardware to remain computationally universal and efficient?
By proving that a Log object—a universal construction—can be implemented with a reduced instruction set, the authors show that any concurrent object can theoretically be built without relying on CAS, paving the way for simpler hardware designs.
Summary updated