jacques

Crates.iojacques
lib.rsjacques
version0.1.1
created_at2025-10-13 02:14:14.335935+00
updated_at2025-10-13 02:37:31.368984+00
descriptionHigh-performance lock-free MPMC queues with horizontal scaling and zero-allocation operation
homepagehttps://github.com/0xAeneas/jacques
repositoryhttps://github.com/0xAeneas/jacques
max_upload_size
id1879926
size234,238
DrAeneas (0xAeneas)

documentation

https://docs.rs/jacques

README

Jacques

High-performance, lock-free Multi-Producer Multi-Consumer (MPMC) queue library designed for concurrent applications requiring maximum throughput and minimal latency. Based on the queue implementation of Erez Strauss.

Features

  • Lock-free algorithms: Zero mutex contention with atomic operations
  • MPMC support: Multiple producers and consumers can operate concurrently
  • Zero-allocation operation: No dynamic allocation during push/pop operations
  • Horizontal scaling: Pack-based load distribution across multiple queues
  • Type safety: Comprehensive compile-time guarantees with generic design
  • Memory efficient: Packed 128-bit atomic operations with sequence numbers
  • Rich API: Blocking, non-blocking, conditional, and bulk operations

Performance Characteristics

  • Throughput: >100M operations/second on modern hardware
  • Latency: Sub-microsecond operation latency
  • Scalability: Linear scaling with core count using queue packs
  • Memory: Constant memory usage, no dynamic allocation

Queue Types

Owned Queue (MpmcQueue)

The foundational lock-free queue for Copy types:

use jacques::{
    owned::queue,
    traits::{QueueConsumer, QueueProducer},
};

let (producer, consumer) = queue::<u64>().capacity(1024).channels()?;

producer.push(42)?;
assert_eq!(consumer.pop()?, 42);

Pointer Queue (PointerQueue)

Store non-Copy types by wrapping them in Arc<T>:

use jacques::pointer::pointer_queue;
use std::sync::Arc;

#[derive(Debug, Clone, PartialEq)]
struct Message {
    id: u64,
    data: Vec<u8>,
}

use jacques::traits::{QueueConsumer, QueueProducer};
let (producer, consumer) = pointer_queue::<Message>().capacity(512).channels()?;

let msg = Arc::new(Message {
    id: 1,
    data: vec![1, 2, 3],
});
producer.push(msg.clone())?;
assert_eq!(consumer.pop()?, msg);

Queue Pack (QueuePack)

Horizontal scaling with multiple independent queues:

use jacques::pack::queue_pack;
use jacques::traits::{QueueConsumer, QueueProducer};

// 4 queues, scan every 16 operations
let (producer, consumer) = queue_pack::<u64, 4, 16>().queue_capacity(256).channels()?;

producer.push(100)?;
assert_eq!(consumer.pop()?, 100);

Advanced Features

  • Sequence Numbers: Track operation ordering across concurrent access
  • Conditional Operations: Process elements based on predicates
  • Bulk Processing: Consume multiple elements efficiently
  • Thread Safety: All queue types are Send + Sync

Installation

Add this to your Cargo.toml:

[dependencies]
jacques = "0.1"

Documentation

For full documentation, visit docs.rs/jacques.

Minimum Supported Rust Version (MSRV)

Jacques requires Rust 1.88 or later.

License

Licensed under either of:

at your option.

Commit count: 0

cargo fmt