Skip to main content

Module mpscq

Module mpscq 

Source
Expand description

A low-latency implementation of MPSC (multi-producer single-consumer) queue

§Benchmarks

Observed latency for push and drain operations,

NOTE: All measurements include end-to-end operation cost (incl. allocations & deallocation)

| Operation | Latency (average)  |
|:----------|:-------------------|
| Push      | ~36 nanoseconds    |
| Drain     | ~37 nanoseconds    |

Environment used for benching,

  • OS: NixOS (WSL2)
  • Architecture: x86_64
  • Memory: 8 GiB RAM (DDR4)
  • Rust: rustc 1.86.0 w/ cargo 1.86.0
  • Kernel: Linux 6.6.87.2-microsoft-standard-WSL2
  • CPU: Intel® Core™ i5-10300H @ 2.50GHz (4C / 8T)

§Example

use frozen_core::mpscq::MPSCQueue;

let queue = MPSCQueue::<usize>::default();

queue.push(0x10);
queue.push(0x20);

let batch: Vec<usize> = queue.drain();
assert_eq!(batch.len(), 2);

Structs§

MPSCQueue
A low-latency implementation of MPSC (multi-producer single-consumer) queue