How chuck-ie/order-book works
This Rust library implements several limit-order matching engines, exposing order placement, cancellation, matching, best-price and volume queries. Its main workflow is a caller submitting a place or cancel command to a matcher, which updates a price-level book and, for arena-backed variants, uses shared arena storage. The repository also provides bounded concurrent channels and an explicit benchmark-and-charting capability. Engine behavior is sampled for selected versions; the README documents the variants and performance comparisons, but benchmark runner wiring is only partially sampled.
Main entry points: common.rs Matcher API · slot_map/mod.rs Slot-map API · channel/mod.rs Channel API · matcher.rs V4 matcher
Components 25
Matching engines
- Matcher API
src/common.rs - Order types
src/engine/mod.rs - V1 matcher
src/engine/v1_vec_only/matcher.rs - V1 Vec book
src/engine/v1_vec_only/book.rs - V2 matcher
src/engine/v2_btree/matcher.rs - V2 BTree book
src/engine/v2_btree/book.rs - V3 matcher
src/engine/v3_slot_map/matcher.rs - V3 slot-map book
src/engine/v3_slot_map/book.rs - V4 matcher
src/engine/v4_sm_arena/matcher.rs - V4 arena book
src/engine/v4_sm_arena/book.rs - V5 matcher
src/engine/v5_sm_arena_vec_index/matcher.rs - V5 indexed book
src/engine/v5_sm_arena_vec_index/book.rs - Arena matcher API
src/engine/arena_order_matcher.rs
Storage
- Arena allocator
src/arena_allocator.rs - Slot-map API
src/slot_map/mod.rs - Standard slot map
src/slot_map/standard.rs - Optimized slot map
src/slot_map/optimized.rs - Chunked slots
src/slot_map/chunked.rs
Channels
- Channel API
src/channel/mod.rs - Ring buffer
src/channel/ring_buffer.rs - Producers
src/channel/producer.rs - Consumers
src/channel/consumer.rs
Benchmarking
- Engine benchmarks
benches/shared/bench_engine.rs - Result charts
benches/create_charts.rs
Other components
- Library caller
Connections 27
- Library caller → Matcher API: submits commands
- Matcher API → V1 matcher: dispatches
- Matcher API → V2 matcher: dispatches
- Matcher API → V3 matcher: dispatches
- Matcher API → V4 matcher: dispatches
- Matcher API → V5 matcher: dispatches
- V1 matcher → V1 Vec book: updates and queries
- V2 matcher → V2 BTree book: updates and queries
- V3 matcher → V3 slot-map book: updates and queries
- V4 matcher → V4 arena book: updates and queries
- V5 matcher → V5 indexed book: updates and queries
- V4 matcher → Arena allocator: allocates and accesses
- V5 matcher → Arena allocator: allocates and accesses
- V4 arena book → Chunked slots: stores orders
- V5 indexed book → Chunked slots: stores orders
- Arena matcher API → Arena allocator: accepts arena
- Slot-map API → Standard slot map: defines implementations
- Slot-map API → Optimized slot map: defines implementations
- Slot-map API → Chunked slots: defines implementations
- Channel API → Ring buffer: constructs
- Channel API → Producers: exposes
- Channel API → Consumers: exposes
- Producers → Ring buffer: writes items
- Consumers → Ring buffer: reads items
- Engine benchmarks → Matcher API: benchmarks engines
- Engine benchmarks → Arena matcher API: benchmarks arena engines
- Result charts → Engine benchmarks: visualizes results