Engine and benchmarks

How the matching engine is built and how its speed is measured. Live figures from the running engine are on the home page.

VerifyEIP-712 recover and account checks before a command enters the queue.
SequenceThe market's thread numbers the command.
MatchPrice-time book, fills at the maker's price.
LogCommand and events appended to the hash chain.
SettleFills grouped into the next numbered batch.
One market, one thread. Commands are numbered, applied, logged and batched.

Design

The engine is written in Rust. Each market runs on its own thread with its own book and log, so markets never contend. Matching is deterministic: the same commands in the same order always produce the same events and the same log hash. Anything time-based, such as expiry, is decided before a command reaches the book.

Method

Benchmarks use criterion. The suite is in the engine's benches/matcher.rs:

cargo bench --bench matcher

Results

BenchWhat it measuresResult (one core)
restRest a limit order on an empty level51.1 ns
cancelCancel a resting order121.2 ns
take_1Take one resting order86.2 ns
sweep_5_levelsSweep five price levels5,506.5 ns
mixedMixed flow, book only18,467,000 orders/s
mixed_with_logMixed flow with the hash-chained log2,383,000 orders/s
verifyEIP-712 recover of one order39.5 µs