A single-threaded, lock-free Limit Order Book built from first principles in Rust. Zero-alloc hot path. Cache-line aligned. Price-time priority.
HdrHistogram latency tracking · Release build · Native hardware
Each crate owns exactly one responsibility. Clean boundaries make the hot path measurable and auditable.
Price-time priority order book. Zero-alloc hot path. Pre-allocated object pool for 1M orders. #[inline(always)] throughout.
Single-producer single-consumer lock-free queue. 128-byte cache-line padding prevents false sharing between producer and consumer cursors.
Zero-copy parsing with bytemuck. 64-byte fixed messages — exactly one cache line. No serialization overhead.
mio-based async TCP server. Non-blocking I/O without Tokio overhead. Feeds orders into the ring buffer from the network layer.
UDP multicast publisher. Fills broadcast to subscribers after matching. Designed for the exchange-side data distribution pattern.
RDTSC cycle-accurate timing. HdrHistogram percentile tracking. Measures P50/P90/P99/P99.9/Max with nanosecond resolution.
Synthetic load generator. Replays order sequences to measure throughput and latency under controlled, reproducible conditions.
Wires all crates into a running node. Manages lifecycle — startup, shutdown, and signal handling for the full exchange stack.
An order travels from TCP socket to match result without a single heap allocation.
Every line in the hot path has a reason.
The Order struct fits exactly one L1 cache line. Hot fields first, cold fields after — so a cache miss on metadata never stalls a match.
Prices are stored as integer ticks, not floats. No rounding errors, no NaN, no IEEE 754 surprises. Deterministic comparisons every time.
1M orders allocated upfront at startup. The hot path never touches the allocator. Zero malloc latency spikes under load.
Write and read cursors are padded to 128 bytes — two cache lines. Producer and consumer run on separate cores without false sharing.
Every subsystem tested independently. Every edge case covered.
Three commands to see 12.8M matches/sec on your own hardware.