---
title: "Who Owns the Wheel (retiring stash and scheduler for the `wheel` timer library)"
authors:
  - "Germán Méndez Bravo"
year: 2026
venue: "Kronuz blog, Familiars series part 35 (kronuz.github.io), 11 Nov 2026, updated 12 Nov"
arxiv: null
doi: null
source: "https://kronuz.github.io/blog/retiring-the-sparse-wheel/"
version_reviewed: "web 2026-11-12 update"
topics:
  - "timer-wheels"
  - "lock-free"
  - "intrusive-data-structures"
  - "event-loops"
  - "single-owner-concurrency"
  - "deterministic-simulation"
seed_rank: 2771
seed_batch: "craft-2026-12-01"
reviewed: "2026-12-01"
pool: "systems"
relevance_score: 8
lineage: realtime-scheduling
cites:
  - title: "Who Owns the Wheel"
    url: "https://kronuz.github.io/blog/retiring-the-sparse-wheel/"
    year: 2026
    arxiv: null
    doi: null
  - title: "The Sparse Wheel"
    url: "https://kronuz.github.io/blog/the-sparse-wheel/"
    year: 2026
    arxiv: null
    doi: null
see: []
---

# Who Owns the Wheel (retiring stash and scheduler for the `wheel` timer library)

## One-sentence takeaway

The author retires his own lock-free shared timer wheel ("stash", where any thread files into append-only leaves and cancels are just flags) in favour of `wheel`: a header-only C++20 hierarchical wheel owned by one thread, with intrusive entries and a 64-stripe lock-free inbox for cross-thread arms. Measured on the same harness, a full arm/re-arm/cancel/expire life costs 42 ns against 1,110 ns at 1,000 entries (26×) and 407 against 1,231 ns at a million. Cross-thread arms cost 12–32 ns against 148–307 ns, and the wheel does no per-entry allocation.

## Why it matters here

This is a clean, measured example of the Anoptic concurrency stance: put the hot structure on its owner and make the cross-thread edge a cheap lock-free push (one CAS on a per-thread stripe), rather than making the shared structure lock-free. The striped inbox (one cache line per stripe, a per-thread head, and an owner that takes the stripe bitmap with one exchange) fits Anoptic's buses. The intrusive `timer_entry` with a `pprev` back-pointer gives O(1) unlink anywhere with no allocation. For GRID COMMAND, the wheel never reads a clock: "a simulator feeds it a counter and runs a day of timers in no time". That is exactly what a lockstep sim wants for cooldowns, build timers and debounced AI re-plans. It also reads as a modern practice note on card 2443 (Varghese–Lauck 1987), though the post does not cite that paper.

## Key ideas

- **Why stash lost.** Append-only leaves make producers lock-free but make removal impossible. Every re-arm is a new filing plus a stale copy the expiry walk must visit (about two of every three entries it meets). That suits fire-and-forget timers but fails for heartbeats, deadlines that are nearly always cancelled, and debounced fsyncs.
- **Layout.** Level 0 has 4,096 slots of 1 ms, with six levels of 64 slots above it, reaching 142 years, so every 64-bit nanosecond deadline has a slot. A parallel bitmap marks occupied slots, and `next()` uses `std::countr_zero` (a far jump walks at most 65 words: 201.6 ns against 264.4 for bit-by-bit). An entry cascades at most six times and fires at most one tick late, never early.
- **Fire safety.** `expire(now)` first files queued remote arms, then moves all due entries to a detached list before running any callback, so a fire may cancel or re-arm any entry, itself included.
- **Two ownership rules (asserted in Debug).** Only the owner arms, re-arms, cancels and expires. Any thread may arm an unarmed entry through the inbox, and after that only the owner touches it. None of the wheel's own state is atomic.
- **Honest losses.** Remote cancel is impossible (it becomes a flag). Cancel is slower than stash's flag clear (3.7 against 0.66 ns at 1k entries). Bursts above about 110 M arms/s back up the inbox (worst fire 3.5–4.1 ms at 4–14 producers, against stash's 1.02 ms). An empty wheel costs 65,552 bytes against 9,248.

## Caveats

This is the author's own benchmark: medians on one 16-thread Intel laptop under macOS. Linux was not measured, and the tail latency of the striped push was not measured either. It is a blog post plus a young repository (created 12 Nov 2026), and the motivating workloads are server timers (consensus heartbeats, fsync debouncers), not games. The 1 ms level-0 tick is coarse for frame-level work unless the sim drives its own counter. I read the full post and checked that the repository exists, but did not run or read the header.

## Links

- Post: https://kronuz.github.io/blog/retiring-the-sparse-wheel/
- Library (header-only C++20): https://github.com/Kronuz/wheel
- Benchmark record: https://github.com/Kronuz/Detent/blob/main/docs/perf/wheel-vs-stash.md
- Predecessor post (stash): https://kronuz.github.io/blog/the-sparse-wheel/
- Varghese & Lauck 1987 (background, not cited by the post): https://doi.org/10.1145/41457.37504
