Swap Queue
A lock-free thread-owned queue whereby tasks are taken by stealers in entirety via buffer swapping. This is meant to be used [thread_local
] paired with [tokio::task::spawn
] as a highly-performant take-all batching mechanism and is around ~11-19% faster than [crossbeam::deque::Worker
], and ~28-45% faster than [tokio::sync::mpsc
] on ARM.
Example
use Worker;
use ;
// Jemalloc makes this library substantially faster
static GLOBAL: Jemalloc = Jemalloc;
// Worker needs to be thread local because it is !Sync
thread_local!
// This mechanism will batch optimally without overhead within an async-context because take will poll after everything else scheduled
async
Benchmarks
Benchmarks ran on t4g.medium running Amazon Linux 2 AMI (HVM)
CI tested under ThreadSanitizer, LeakSanitizer, Miri and Loom.