⚡ Rust Nightly · MIT License · 33 Tests Passing

12.8M matches/sec.
Sub-microsecond.

A single-threaded, lock-free Limit Order Book built from first principles in Rust. Zero-alloc hot path. Cache-line aligned. Price-time priority.

Real Numbers. Measured with RDTSC.

HdrHistogram latency tracking · Release build · Native hardware

0 ns P50 Latency (Target <20μs)
12.8× Over 1M/sec target
64 B Order struct (1 cache line)
0 Heap allocs on hot path

8 Crates. Zero Compromise.

Each crate owns exactly one responsibility. Clean boundaries make the hot path measurable and auditable.

titan-core

Matching Engine

Price-time priority order book. Zero-alloc hot path. Pre-allocated object pool for 1M orders. #[inline(always)] throughout.

titan-ring

SPSC Ring Buffer

Single-producer single-consumer lock-free queue. 128-byte cache-line padding prevents false sharing between producer and consumer cursors.

titan-proto

Binary Protocol

Zero-copy parsing with bytemuck. 64-byte fixed messages — exactly one cache line. No serialization overhead.

titan-net

TCP Gateway

mio-based async TCP server. Non-blocking I/O without Tokio overhead. Feeds orders into the ring buffer from the network layer.

titan-feed

Market Data Feed

UDP multicast publisher. Fills broadcast to subscribers after matching. Designed for the exchange-side data distribution pattern.

titan-metrics

Latency Metrics

RDTSC cycle-accurate timing. HdrHistogram percentile tracking. Measures P50/P90/P99/P99.9/Max with nanosecond resolution.

titan-replay

Benchmark Suite

Synthetic load generator. Replays order sequences to measure throughput and latency under controlled, reproducible conditions.

titan-node

Node Orchestrator

Wires all crates into a running node. Manages lifecycle — startup, shutdown, and signal handling for the full exchange stack.

Data Flow — Zero Copy, End to End

An order travels from TCP socket to match result without a single heap allocation.

Client
TCP/UDP
──▶
titan-net
mio Gateway
──▶
titan-proto
Zero-Copy Parse
──▶
titan-ring
Lock-Free SPSC
──▶
titan-core
⚡ Match Engine
└──▶
titan-feed
UDP Multicast
──▶
Subscribers
Market Data
+ titan-metrics tracks every nanosecond

Engineering Decisions That Matter

Every line in the hot path has a reason.

64-Byte Cache-Aligned Order

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.

// Exactly one cache line #[repr(C, align(64))] pub struct Order { // HOT (first 32 bytes) order_id: OrderId, // 8B remaining_qty: Quantity, // 8B price: Price, // 8B timestamp: u64, // 8B // COLD original_qty: Quantity, // 8B symbol: SymbolId, // 4B side: Side, // 1B _padding: [u8; 19], // pad to 64B }

Fixed-Point Arithmetic

Prices are stored as integer ticks, not floats. No rounding errors, no NaN, no IEEE 754 surprises. Deterministic comparisons every time.

// No floats. Ever. pub struct Price(u64); pub struct Quantity(u64); // 100.11 stored as 10011 ticks // Comparison is a single integer op if bid.price >= ask.price { // guaranteed match }

Pre-Allocated Object Pool

1M orders allocated upfront at startup. The hot path never touches the allocator. Zero malloc latency spikes under load.

// Allocate once at startup let pool = OrderPool::with_capacity( 1 << 20 // 1M orders ); // O(1), no malloc on hot path let handle = pool.allocate().unwrap();

128-Byte Ring Buffer Padding

Write and read cursors are padded to 128 bytes — two cache lines. Producer and consumer run on separate cores without false sharing.

// 128B = 2 cache lines apart #[repr(C, align(128))] struct PaddedAtomic { value: AtomicU64, _pad: [u8; 120], } // Write cursor → producer core // Read cursor → consumer core // Zero false sharing ✓

33 Tests. 0 Failures.

Every subsystem tested independently. Every edge case covered.

✓ 33 passed  ·  0 failed  ·  0 ignored
titan-core 21 ✓
  • test_simple_match
  • test_partial_fill
  • test_price_time_priority
  • test_ioc_no_match
  • test_post_only_reject
  • test_order_size (64 bytes)
  • test_pool_exhaustion
  • + 14 more
titan-proto 5 ✓
  • zero-copy parse round-trip
  • 64-byte message size
  • bytemuck alignment
  • endian correctness
  • malformed input guard
titan-ring 5 ✓
  • producer/consumer ordering
  • wrap-around correctness
  • full buffer blocking
  • 128B padding verified
  • lock-free under load
titan-metrics 2 ✓
  • RDTSC monotonicity
  • HdrHistogram percentiles

Clone. Build. Benchmark.

Three commands to see 12.8M matches/sec on your own hardware.

# Clone and build git clone https://github.com/DevWizard-Vandan/Titan cargo build --workspace --release # Run the benchmark suite cargo run -p titan-replay --release