ptab 0.1.7

Lock-free concurrent table optimized for read-heavy workloads
Documentation

ptab

github crates.io docs.rs build status

A lock-free concurrent table for Rust.

ptab provides a fixed-capacity table optimized for read-heavy concurrent workloads. Inspired by Erlang's BEAM process table, lookups scale linearly with CPU count by avoiding all shared memory writes.

Features

  • Zero-contention reads - Atomic loads for lock-free lookups.
  • Cache-line distribution - Prevents false sharing with no memory overhead.
  • Generational indices - Slot reuse mitigates ABA problems.

Usage

Add the following to your Cargo.toml:

[dependencies]
ptab = "0.1"

Example

use ptab::PTab;
use std::sync::Arc;

let table = Arc::new(PTab::<&str>::new());

let handle = std::thread::spawn({
  let table = Arc::clone(&table);
  move || table.insert("world").unwrap()
});

let index_a = table.insert("hello").unwrap();
let index_b = handle.join().unwrap();

assert_eq!(table.read(index_a).unwrap(), "hello");
assert_eq!(table.read(index_b).unwrap(), "world");

Design

See IMPLEMENTATION.md for detailed design notes.

License