Crate nexus_queue

Crate nexus_queue 

Source
Expand description

High-performance lock-free queues for latency-critical applications.

nexus-queue provides bounded SPSC (single-producer, single-consumer) queues optimized for trading systems and other low-latency workloads.

§Quick Start

use nexus_queue::spsc;

let (mut tx, mut rx) = spsc::ring_buffer::<u64>(1024);

tx.push(42).unwrap();
assert_eq!(rx.pop(), Some(42));

§Implementations

Two SPSC implementations are available with different performance characteristics depending on hardware topology:

  • index (default): Cached head/tail indices on separate cache lines
  • slot: Per-slot lap counters on the same cache line as data

The key difference is cache line ownership. The index-based design has producer and consumer writing to separate cache lines, while slot-based has both writing to the same cache line. Which performs better depends on your NUMA configuration and cache hierarchy.

Benchmark both on your target hardware.

# Use slot-based implementation
nexus-queue = { version = "...", features = ["slot-based"] }

§Feature Flags

  • spsc-slot: Use slot-based implementation for top-level re-exports

Modules§

spsc
Single-producer single-consumer bounded queue.

Structs§

Full
Error returned when pushing to a full queue.