Skip to content

Comparison and synthesis ​

What the survey's thirteen lock implementations, four operating-system wait primitives, four async runtimes and twelve papers agree on, where they split, and what that settles for sparkles.base.sync and event-horizon's WaitWord.

Last reviewed: October 12, 2026

IMPORTANT

This page answers the four questions the survey was commissioned for. It recommends; the binding decisions are made in the sparkles.base.sync specification, which cites the sections below.

At a glance ​

SubjectLock wordWaiters live inSpin before sleepingFairnessCondvar requeueFibers / tasks
Rust std3-state futex, u32 (u8 on Windows)the kernel's futex queue100 reads, stops at contendedbarging, no boundno (sequence counter)none
Zig3-state futex, u32kernel futex; own table on Windowsnonebarging, no boundno (epoch + counts)Io vtable: ring FUTEX_WAIT under uring
glibc3-state lll_lockthe kernel's futex queuenone by default; adaptive type opt-inbarging, no boundno (G1/G2 groups, 2016)none
parking_lot1 byte: LOCKED, PARKEDglobal hashed table, per-thread parker3 pause rounds + 7 yields, only if no parkedbarging; explicit fair unlock only at HEADyes (unpark_requeue)none
WebKit WTF::Lock2 bits: isHeld, hasParkedglobal hashed table, per-thread condvartuned pause bursts per platformrandom handoff, ~1 ms per bucketno (herds)none
Go8-byte word: lock bits + waiter countruntime semaRoot treap, 251 buckets4 × 30 PAUSE, only if another P runsbarging, FIFO handoff after 1 msno (ticket list)native: gopark parks the goroutine
Abseil8 bytes: flags + queue pointerqueue hanging off the word1500 CAS retriesdesignated waker; long-wait bityes (Fer, without a wake)none
nsyncword + queue (spinlock bit inside)queue hanging off the locknoneafter 30 failed wakes, waiter goes firstyes (onto the mutex's queue)nsync_wait_n over a vtable
FollyDistributedMutex: tail pointerwaiters' stack nodes (LIFO, combining)~2 µscombining; no FIFO—fibers::Baton: one word, thread or fiber
Java AQSint state + queue head/tailCLH-style queue per lockretries growing to 256barging; fair mode opt-inyes (node moves to lock queue)native: park yields a virtual thread
os_unfair_lockowner's Mach portkernel turnstilekernel-side, while the owner runs (20 µs)none, by name—none
SRWLOCKpointer-sized, zero-initializedunpublished; Wine: RtlWaitOnAddressnone documented; Wine: nonebarging since 2003 SP1nonone; no handle
Linux kernel mutexowner pointer + flag bitsMCS/OSQ while spinning, list when asleepwhile the owner is on a CPUHANDOFF flag after a lost race——
tokiosemaphore permitsintrusive list in the semaphorenonestrict FIFO handoffNotify stores a permitnative (tasks); blocking_lock for threads
event-listenerasync-lock: state wordintrusive list; Waker or Unparkernonebarging, starvation mode after 500 µs—native, threads and tasks share one list
Seastarshard-local countersper-shard intrusive listsnone (one thread)FIFO—native; cross-shard by message only
TrioParkingLot per objectper-object ordered dictnone (one thread)FIFO handoff—native; from_thread to enter
kotlinx MutexCQS segments + counterinfinite array of cells (CQS)noneFIFO, abortable—native (coroutines)

(a) The mutex word ​

Recommendation: a parking-lot lock — two bits of state plus a designated-waker bit, with waiters in a fixed, statically allocated table of address-keyed queues. The three-state futex word is the simpler design and the one three standard libraries chose; the parking lot is the faster and more expressive one once its one pathology is fixed.

What the parking lot buys:

  • Throughput, with the designated waker. On a 32-thread machine (mutex benchmark), a parking lock that wakes at most one waiter at a time — nsync's MU_DESIG_WAKER, Abseil's kMuDesig (nsync § fairness, Abseil) — runs about 2.2× the three-state word's throughput at 32 and 64 threads (≈ 90 against ≈ 41 acquisitions per microsecond) and 3.5–4.5× at 2 and 4 threads, sleeping on 0.002 acquisitions where the three-state word sleeps on 0.04. The benchmark does not give the three-state word an equivalent bit.
  • Wait morphing, exact notifications, handoff. Only a lock whose queue the library owns can have its condition variable requeue waiters onto it, report exactly how many it woke, and hand the lock to a chosen waiter with a token (parking_lot § condition variables; concepts § wait morphing).
  • Locks in two bits of any word. WebKit's LockAlgorithm projects the lock onto any atomic field, so a per-object lock lives in an object header and CountingLock keeps an optimistic-read counter beside it (WebKit). A futex lock needs its own 32-bit word.
  • Richer wakes. unpark_filter wakes all readers and one writer in one pass; forEach and parking_lot's wait-for graph make the waiters inspectable for deadlock detection (parking_lot).
  • One registry for threads and fibers. The table's queue node can hold a thread's parker or a fiber's loop waker; see (d).
  • No empty-wake system calls. An unlock with no sleeper never enters the kernel, and a wake targets one thread's own word, so the kernel's futex hash sees one waiter per word. An empty FUTEX_WAKE costs about 270 ns against 1.6 ns for an uncontended acquire and release (Linux § cost).

Why the standard libraries chose otherwise, and why it does not bind here:

  • Simplicity. Rust's 2022 decision: a futex lock "is simple and easy to implement and verify, as it leaves most of the complexity to the kernel" (Rust § overview). An implementation-cost argument.
  • Bootstrapping. Rust also rejected parking_lot because its table grows by allocating, and an allocator may itself take a lock (Rust § overview). Growth is parking_lot's choice, not the design's: Go's runtime table has 251 buckets, Zig's 256, Wine's WaitOnAddress 256 and Folly's ParkingLot 4096, all fixed (Go, Zig § parking substrate, Windows § how it works, Folly). With a fixed table and waiter records in thread-local storage or a fiber's frame, the lock never allocates.
  • The convoy. parking_lot as shipped collapses once the cores are saturated: its own benchmark, built from HEAD and from 0.12.5, runs 6–8× slower than std::sync::Mutex at 32 and 64 threads while winning by 1.3–1.6× at 2 and 4 (8 iterations inside the lock, 16 outside, one second per cell, measured locally on 2026-10-11). Its PARKED bit is exact, so every unlock while the queue is non-empty wakes a waiter that loses the race to a running thread and parks again — 0.8–0.97 sleeps per acquisition in the port. Spinning despite PARKED does not cure it; the designated-waker bit does (concepts § convoys).

What the specification must still decide:

  • Collisions. Locks whose addresses share a bucket share its lock and its queue scan; the table's size and per-bucket structure (a list, Go's treap) set the cost.
  • Owner identity. Spinning only while the owner runs, and priority inheritance, both need the owner in the word (queue locks § spinning, os_unfair_lock § state word). Neither design has it in two bits.
  • Scope. A parking lot is process-private, and its operations are not async-signal-safe (parking_lot § async).

(b) The condition variable ​

Recommendation: wait morphing over the parking lot — parking_lot's Condvar: one pointer naming the mutex, notify_one requeuing a waiter onto the mutex's queue when the mutex is held, notify_all requeuing all of them, and exact notification results with no spurious wakeups (parking_lot § condition variables).

  • glibc's case against requeue does not apply. Riegel dropped FUTEX_CMP_REQUEUE in 2016 because, over a futex word, requeue forces every waiter to drive the mutex into contended so each release pays a wake; it prevented lock elision; and "it should be the mutex who decides" (glibc § condition variables). In a parking lot the requeue runs under the bucket lock and have_more_threads keeps PARKED exact, so no release pays an unneeded wake; glibc itself deprecated elision in 2.42 and removed it in 2.43 (glibc); and parking_lot's condvar asks the mutex (mark_parked_if_locked) before choosing requeue or wake.
  • It removes the herd. WebKit's Condition, with no requeue, makes every notifyAll herd (WebKit § condition variables); Abseil's Fer, nsync and Java AQS move signalled waiters onto the lock queue instead (Abseil, nsync § condition variables, AQS § fairness).
  • Exactness is cheap here, not there. glibc's G1/G2 groups bought ordering over a futex at 48 bytes, an internal lock per signal and a lost-wakeup bug that stood from 2.25 to 2.41 (glibc § condition variables). Over an owned queue, ordering is the queue's order.
  • The kernel's wake counts never matter. Only Linux reports how many it woke (FreeBSD § wake counts); the parking lot counts its own queue.

Predicate waits (Abseil's Await, nsync's nsync_mu_wait) evaluate predicates on the unlocking thread and grow with the number of distinct false predicates (nsync § condition variables); over an owned queue they are an addition the design permits, not a primitive it needs.

(c) Fairness and spinning ​

Recommendation: barge by default; bound starvation by a count of failed wakes, handing the lock to the designated waker once it is exceeded; spin briefly before parking.

  • Handoff convoys are why everyone barges. MCS's own 1991 paper recommends against FIFO spinning when waiters can be preempted; Windows SRW and Java AQS moved to barging for the same reason (AQS § fairness, SRW), and the CQS evaluation finds strict FIFO does not pay for a single-permit mutex (CQS).
  • Bounds without a clock exist. The Linux kernel mutex lets a woken waiter that lost the race set HANDOFF, and the next unlock hands it the lock (queue locks § fairness); nsync's waiter takes the front after 30 failed wakeups (nsync § fairness). The parking lot's UnparkToken is the handoff channel. Timer bounds — Go's 1 ms, WebKit's random ~1 ms, async-lock's 500 µs — read a clock on the slow path, and parking_lot removed its timer at HEAD without a stated reason (parking_lot § fairness).
  • No OS gives FIFO wakeups. Linux wakes by priority then FIFO, Darwin's turnstiles by priority; Windows documents FIFO but calls it descriptive (Windows § semantics). A parking lot's own queue is the only ordered one.
  • Spin budgets span three orders of magnitude — none (Zig, nsync, os_unfair_lock), 14 pauses and 7 yields (parking_lot), 100 reads (Rust), 4 × 30 PAUSE (Go), 2 µs (Folly), 1500 CAS (Abseil) — and only the owner-aware ones are principled; WebKit tunes its pause bursts per platform (WebKit § spinning).
  • Fibers change the spin. A cooperative scheduler can deadlock a pure spinner whose holder yielded; spin → yield → suspend is the safe ladder, and its best mix depends on the runtime (Skazhenik 2025).

(d) Fibers waiting on a word: the WaitWord registry ​

A loop-resident fiber must wait on a word without blocking its loop's thread, and be woken by any thread. The survey offers three shapes.

  1. The kernel futex queue, through the ring. Under io_uring (6.7+), a fiber's wait is IORING_OP_FUTEX_WAIT and any thread's plain FUTEX_WAKE produces a completion (Linux § event-loop integration); Zig's Io.Uring does exactly this (Zig § async). Linux only.
  2. One parking entry point that knows the waiter's kind. Java's LockSupport.park yields a virtual thread and blocks a platform thread, so every java.util.concurrent lock became fiber-safe unchanged (AQS § async); event-listener stores a task Waker or a thread Unparker per entry (smol § async); Folly's fibers::Baton holds a thread or a fiber waiter in one word (Folly); Go's gopark is the runtime-native version (Go).
  3. A user-space registry plus a doorbell. Where the OS cannot report an address wait as a completion — WaitOnAddress has no handle for IOCP, kqueue has no address filter — the waker finds the fiber in a user-space table and posts to its loop (Windows § event-loop integration, Darwin § event-loop integration).

Recommendation: the parking lot of (a) is the registry — shape 2 built on shape 3. A queue node carries either a thread's parker or a fiber's loop waker; park asks the current context which, and every primitive — Mutex, Condition, RwLock, Semaphore, WaitWord — becomes fiber-aware on every OS at once, as Java's did. Shape 1 remains an optimization for a plain WaitWord on Linux, not the mechanism. The registry's rules come from the survey:

  • Two-phase wake. Choose the waiter and commit the token under the bucket lock; deliver the wake — a futex wake, an io_uring message, an IOCP packet, an EVFILT_USER trigger — after releasing it, as parking_lot's unpark_lock/unpark does (parking_lot § async).
  • Address-keyed, tolerant of stale wakes. A wake can reach freed or reused memory (glibc; concepts § spurious wakeups).
  • A seq_cst edge between publishing and reading the waiter's state. The "announce sleeping, re-check, block" handshake loses wakeups with only release/acquire (Enberg 2019).
  • Cancellation never loses a wake. A cancelled waiter that was already chosen passes its wake or token on (tokio, event-listener, Seastar, Trio — tokio § fairness; CQS).
  • Multi-wait by one state cell. A fiber waiting on several words gets one WAITING → SYNCHED cell, entered in every queue, won by one CAS; losing queues keep dead entries to sweep (Reppy 1991).
  • Resume locally when handing off. Dispatching the woken fiber to a ready queue leaves the lock idle for the queueing delay; resuming it on the releasing thread and requeuing the releaser fixes that (CES: König 2025; Go's starvation mode already does it).

Delta: Sparkles today ​

CapabilityPrior artSparkles today
Wait-on-address seam per OSRust sys::futex, Zig Futexraw FUTEX_WAKE in event-horizon's Waker only (Linux)
Parking lot with callbacksWebKit ParkingLot, parking_lot_core, Go semanone
Parking-lot mutex, designated wakerparking_lot, nsync, Abseilnone; core.sync.mutex (pthread_mutex_t) everywhere
Wait-morphing condvarparking_lot, Abseil, nsync, Java AQScore.sync.condition (pthread)
Once without pthreadparking_lot Once, Go sync.Oncea static pthread_mutex_t guards the shared blocking pool
Fiber-aware waitingJava park, event-listener, Folly Batonin-ring FUTEX_WAIT for the loop's own waker; no user-facing op
Cross-thread wake into a loopSeastar membarrier, Go netpoll breakWaker: futex word (uring), EVFILT_USER (kqueue), IOCP packet

Sources ​

Every row above cites the deep-dive it summarizes; the deep-dives cite source trees pinned to commits and the papers' full texts.