UBQ
UBQ is a lock-free queue built from linked blocks, intended for concurrent producers and consumers.
Usage
Add UBQ to your Cargo manifest:
= "0.1"
A minimal example that allocates a small ring of blocks and moves a value through it:
use UBQ;
See the full API docs on docs.rs and the crate page on crates.io.
Benchmarks
This repo includes a custom benchmark harness that compares UBQ against other unbounded queues in SPSC, MPSC, SPMC, and MPMC scenarios. Results are emitted as JSON, and a helper script can generate four throughput bar plots (one per scenario).
Run the default benchmark suite (release mode) and write results to a file:
Limit to a subset of queues or scenarios:
Generate plots (PNG) and CSVs:
Block size variants
UBQ’s block size can be varied via feature flags (compile-time). To layer multiple UBQ block sizes in the same plots, run the base comparison once, then add UBQ-only runs for other sizes and pass all JSON files to the plotting script:
# Base comparison (all queues, default block size).
# UBQ-only runs with alternative block sizes.
# Combined plot with layered UBQ sizes.
The benchmark JSON includes per-run producer/consumer counts, the measured throughput (ops/sec), and component timings (push completion, pop completion, fill/drain durations).
Debug logging
Enable ubq_debug to collect thread-local logs from UBQ internals:
use ;
set_thread_label;
ubq_log!;
// ... run UBQ operations ...
let entries = take;
for entry in entries
Write the current thread’s log buffer to a directory:
flush_to_dir.expect;
For the mpmc_integrity_smoke test, you can set UBQ_DEBUG_DIR=ubq_logs to emit one log file per thread.
You can also limit log volume:
UBQ_DEBUG_TAGS=pop.goto_next,push.new_blockto only log tagged events with those prefixes.UBQ_DEBUG_SAMPLE=1000to log every 1000th event per thread.UBQ_DEBUG_MAX=50000to cap entries per thread.- Reset logging uses tags
reset.attempt,reset.success, andreset.skip.
Loom model checking
UBQ includes opt-in loom tests for deterministic interleaving exploration of high-contention block-boundary scenarios:
LOOM_MAX_PREEMPTIONS=3
By default, the scenario runner caps model exploration at 200 permutations for
practical runtime; override with LOOM_MAX_PERMUTATIONS.