TL;DR
Researchers from IIT Delhi have developed what they believe to be the first general-purpose, wait-free concurrent stack. By decoupling the "pop" operation from the stack's top pointer and using a lazy cleanup mechanism to prune deleted nodes, the algorithm achieves high parallelism and superior fairness compared to traditional lock-free designs.
What Problem Does This Paper Address?
In concurrent programming, a stack is a notoriously difficult data structure to scale. Because all push and pop operations must happen at the "top," this single memory location becomes a massive bottleneck (contention).
Most existing high-performance stacks are lock-free, meaning the system as a whole always makes progress, but individual threads can "starve" (get stuck in an infinite loop) if they keep losing races to update the top pointer. Wait-free structures are the gold standard because they guarantee that every thread will finish its operation in a finite number of steps. However, building a wait-free stack that doesn't have major restrictions (like limiting the number of threads or allowing the memory usage to grow infinitely) has remained an open challenge.
Methods
The authors introduce a novel algorithm that relies on three main pillars:
- The "Helping" Push: To ensure wait-freedom, the
pushoperation uses an "announce array." When a thread wants to push, it posts its intent. Other threads check this array and help complete pending pushes before starting their own. This ensures no single thread is left behind. - The Non-Modifying Pop: This is the "aha!" moment. In this design, a
popoperation does not update the top pointer. Instead, it starts at the current top and walks down the stack (followingprevpointers) until it finds a node that isn't "marked." It marks that node as popped and returns the value. Becausepopdoesn't move the top pointer, multiplepopoperations can run in parallel without fighting over the same memory address. - Lazy Cleanup: Since
popdoesn't actually remove nodes, the stack would eventually grow to an infinite size with "zombie" (marked) nodes. The authors implement acleanuproutine that is triggered every $W$ operations (where $W$ is a tunable parameter). This routine physically removes sequences of marked nodes from the linked list, keeping the stack size within a factor of $W$ of the actual number of elements.
Datasets
As this is a fundamental data structure paper, the authors did not use external datasets. Instead, they evaluated their algorithm using synthetic concurrent workloads designed to stress-test the stack under high thread contention. They compared their Wait-Free (WF) implementation against the standard Treiber lock-free (LF) stack and a traditional locked (LCK) stack.
Key Insights and Ideas
- Top Pointer Monotonicity: By making the
toppointer only move "up" (during pushes) and never "down" (during pops), the authors drastically reduce the complexity of managing the stack's state. - Logical vs. Physical Deletion: Separating the intent to pop (marking a node) from the maintenance of the list (cleanup) allows the "fast path" of the stack to remain highly concurrent.
- The $W$ Parameter: The algorithm introduces a clever trade-off. A small $W$ keeps memory usage tight but increases cleanup overhead; a large $W$ improves speed but allows the internal linked list to grow longer. This allows engineers to tune the stack for specific hardware or memory constraints.
Key Results
- Fairness: The wait-free stack achieved an average fairness of ~80%, significantly outperforming the lock-free stack (~50%) and the locked stack (~25%). In this context, fairness means the work is distributed evenly across all threads rather than a few "lucky" threads doing all the processing.
- Throughput Consistency: In the wait-free version, almost all threads completed more than 90% of their assigned work within the test window. In the lock-free version, only 11 out of 64 threads reached that level of completion, with some threads finishing as little as 40% of their work due to starvation.
- Linearizability: The authors provide a formal proof that despite the "lazy" nature of the pops and cleanups, the stack always behaves like a correct, sequential stack to the outside observer.
Limitations and Future Work
The primary trade-off in this design is the complexity of the cleanup operation. While push and pop are very fast, the cleanup routine is relatively "heavy" and slow. Although it is invoked infrequently (1 out of $W$ times), it represents the "worst-case" path for a thread.
The authors note that they are currently working on further reducing the complexity of the cleanup method to improve practical runtimes. Additionally, while the stack is wait-free, its worst-case time complexity is tied to the stack size ($S$) and the number of threads ($N$), which might be a concern for extremely large-scale systems.
Summary updated