Asymmetry-aware scalable locking

Nian Liu, Jinyu Gu, Dahai Tang, Kenli Li, Binyu Zang, Haibo Chen

TL;DR

Existing scalable locks assume all CPU cores are created equal, but modern asymmetric processors (like Apple’s M1 or Intel’s Alder Lake) prove they aren't. LibASL is a new asymmetry-aware locking library that uses application-defined latency targets to dynamically reorder lock acquisitions, allowing "big" cores to prioritize throughput while ensuring "little" cores meet their deadlines.

What Problem Does This Paper Address?

For decades, multicore software has been designed for Symmetric Multicore Processors (SMP), where every core has identical computing power. However, we have entered the era of Asymmetric Multicore Processors (AMP), which mix high-performance "big" cores with energy-efficient "little" cores.

The authors discovered that traditional locks suffer from "performance collapse" on AMP systems:

  1. Fair Locks (e.g., MCS): By giving every core an equal turn, these locks force the entire system to wait for the slower "little" cores to finish their critical sections. This creates a bottleneck that kills overall throughput.
  2. Unfair Locks (e.g., TAS/Spinlocks): These often show "core affinity," where the lock gets passed mostly among one type of core. If the big cores hog the lock, little cores starve; if the little cores win, latency spikes and throughput drops.

The challenge is finding a "sweet spot" that prioritizes fast cores for throughput without violating the latency requirements of the application.

Methods

The authors introduce LibASL, which consists of two main components:

  • The Reorderable Lock: Built on top of standard FIFO (First-In-First-Out) queues, this lock introduces a "standby" state. While big cores can grab the lock immediately if it's free, little cores are often placed in a standby window. During this window, other big cores can "jump the line" and acquire the lock first.
  • SLO-Guided Feedback Mechanism: To prevent big cores from jumping the line indefinitely (which would cause latency to skyrocket), LibASL uses a feedback loop inspired by TCP congestion control. Programmers define a Service Level Objective (SLO)—for example, "99% of requests must finish within 1ms."
    • If the application meets the SLO, LibASL gradually increases the reorder window (allowing more throughput).
  • If the SLO is violated, it exponentially shrinks the window to restore fairness and reduce latency.

Ease of Use: LibASL is designed for low developer effort. It uses "weak-symbol replacement" to transparently intercept standard pthread_mutex_lock calls. Developers only need to add two lines of code to mark the start and end of a "latency-critical epoch" and specify their SLO.

Datasets

The researchers evaluated LibASL on an Apple M1 (4 big cores, 4 little cores) running Linux. They tested the system using:

  • Micro-benchmarks: Custom-built high-contention and highly variable workloads to stress-test the reordering logic.
  • Real-world Databases: Five popular systems including Kyoto Cabinet, upscaledb, LMDB, LevelDB, and SQLite. These represent various storage architectures (In-memory KV, On-disk KV, and relational databases).

Key Insights and Ideas

  • Fairness is a Performance Bug on AMP: In a world of unequal cores, strict fairness is actually detrimental. Prioritizing faster cores is essential for scaling throughput.
  • Bounded Unfairness: You can't just ignore the little cores. Reordering must be bounded. LibASL’s "aha moment" is using the application’s own latency requirements as the boundary for that unfairness.
  • Dynamic Adaptation: There is no "one-size-fits-all" reordering window. Because workloads change, the lock must act like a living organism, constantly adjusting its "greediness" (the reorder window) based on real-time performance.

Key Results

  • Throughput Gains: LibASL improved throughput by up to 5x compared to standard pthread_mutex and 3.8x compared to the popular MCS lock on the Apple M1.
  • Latency Control: Unlike unfair locks (TAS) which can cause 6x higher tail latency, LibASL precisely maintained the P99 tail latency designated by the application, even under highly variable workloads.
  • Database Performance: In upscaledb, LibASL outperformed the TAS lock by 46% in throughput while maintaining a much lower tail latency. In Kyoto Cabinet, it reduced tail latency by 90% compared to TAS while maintaining similar throughput.

Limitations and Future Work

  • SLO Sensitivity: LibASL provides the most benefit when the application has a "loose" SLO. If the SLO is set too tight (near the physical limits of the hardware), LibASL effectively reverts to a standard FIFO lock, losing its throughput advantage.
  • DVFS Awareness: The paper notes that on some platforms, "big" cores might be throttled for power saving, potentially becoming slower than "little" cores. While LibASL's feedback loop handles this eventually, more explicit integration with hardware power states (DVFS) could make it even more responsive.
  • Nested Epochs: While supported, the authors note that if nested epochs have conflicting SLOs, the library defaults to prioritizing the inner-most requirement, which might not always be the optimal global strategy.

Summary updated

BibTeX
@inproceedings{liu2022asymmetry,
  author = {Nian Liu and Jinyu Gu and Dahai Tang and Kenli Li and Binyu Zang and Haibo Chen},
  title = {{Asymmetry-aware scalable locking}},
  booktitle = {PPoPP},
  year = {2022},
  doi = {10.1145/3503221.3508420},
}
Figure