dispenso v1.6.0
Permanent link:
cppdashboard.dev/r/2026/08/dispenso-v1-6-0The project provides high-performance concurrency, enabling highly parallel computation.
Release notes
### New features * **`ChaseLevDeque`** — lock-free single-producer multi-consumer work-stealing deque with dynamic resizing. Classic data structure for work-stealing schedulers. * **`MpmcRingBuffer`** — bounded multi-producer multi-consumer ring buffer with power-of-two capacity and CAS-based push/pop. * **`CpuSet`** — portable CPU affinity and NUMA topology facility. Supports thread-to-core binding, L2/L3 cache group detection, and cache-aware thread group building. Full support on Linux, Windows, and FreeBSD; topology-only on macOS. * **`parallel_invoke`** — fork-join invocation of heterogeneous tasks. Schedules N-1 tasks to the pool and runs the last inline. Composes naturally with recursive divide-and-conquer. * **`kAdaptive` parallel_for** — new chunking strategy inspired by Callisto-RTS (Harris/Kaestle, USENIX ATC 2015). The iteration space is partitioned into P contiguous stripes (one per worker), each consumed front-to-back via per-stripe atomic cursors. When a worker's stripe is exhausted, it steals from peers, preferring same-L3 victims for cache locality. Bitmasks prevent probing exhausted stripes. Competitive with TBB on SpMM benchmarks (3–12% faster at 8–32 threads, within noise at 64–192 threads on 1M-row workloads). * **`when_any` combinator** — returns a future that completes when any input future is ready, with the index of the first completed future. * **`DistributedRWLock`** — sharded reader-writer lock that spreads reader traffic across per-shard state to avoid a single contended cache line, with an OS-level writer drain rather than a spin. Defaults to 16 shards. * **`granularity` option for `parallel_for`** — bounds the smallest unit of work a chunking strategy will hand to a worker, so loops with expensive per-iteration bodies can stop the scheduler from subdividing past the point where the split costs more than the work. * **FreeBSD support** — native thread-pool wait/wake via the `_umtx_op` syscall, plus `CpuSet` CPU-affinity, NUMA-domain, and L2/L3 cache-topology queries built on `cpuset_getaffinity` and the `kern.sched.topology_spec` sysctl. (thanks bimokh!) ### Thread pool rework * **Per-thread rings** — each worker thread gets a dedicated SPMC ring buffer (16 slots). `schedule()` distributes work round-robin across rings, eliminating central queue contention at high thread counts. Foundation for fork-join scheduling — threads check their own ring before the central queue. * **Steal-ring scheduling** — shared steal rings (one per `kStealRingSharing` threads) provide a secondary work-distribution tier between the per-thread ring and the central queue, enabling same-group work stealing without central queue CAS contention. * **Wake cascade** — replaced `wakeN()` bitmask scanning with a promote-seed cascade pattern (O(log N) wake latency). One thread is woken and propagates wakes through the group via pre-staged lambdas in per-thread rings. Pattern C cascade is within ±5% of the old scheme on all benchmarks while being 6x faster on the mandelbrot workload (reverting to old wakeN was +615% on mandelbrot). * **Lean-spin warmup** — idle threads first check only their own ring (no central queue, no CAS contention) for `kSpinCheckInterval` iterations before engaging full work-finding machinery. Minimizes cache-line traffic from idle threads during sustained parallel_for bursts. * **Fixed-spin termination** — replaced adaptive time-based spin backoff with a simple fixed iteration count (`kDefaultSpinLimit`). Eliminates `getTime()` calls from the idle path. Windows defaults to 200 iterations; Linux/macOS to 400. Platform constants are tunable via `-DDISPENSO_TUNE_FIXED_SPIN_ITERS` and `-DDISPENSO_TUNE_SPIN_CHECK_INTERVAL`. * **Separate poll-mode / wake-mode timeouts** — poll-mode timeout (200µs Linux, 1ms Windows) controls how often threads check for work when wake signaling is disabled. Wake-mode backstop (100ms) bounds worst-case latency from rare races. Previously these shared a single c…
Share this resource