systems · sub-star
nano_match
low-latency limit order book and matching engine.
readme
A high-performance order matching engine in C++, built to understand how financial exchanges actually work: price-time priority matching across a limit order book, with the low-level optimizations that low-latency trading systems depend on. The core design decision is refusing to touch the heap on the hot path.
artifact
latency distribution · 0.1µs to 1.5µs
illustrative feed. orders are generated, latencies are mocked, not benchmarked.
signal log
- price-time priority matching over a flat price ladder, with a hierarchical bitmap so finding the next best price is a few word loads however far away it is.
- no allocation after startup: a fixed population of orders circulates between reserved and resting, and a full book rejects rather than grows.
- 12M requests/s at a 50 ns median on one core, and only 18% slower with a million orders resting.
- sequencer lookahead prefetches the id index for requests not yet processed: +44% throughput and half the median latency, for a hint.
- a deterministic simulation checks every operation against a std::map reference book and a full invariant sweep; five deliberately injected bugs were all caught within 25 steps.
built with
C++17