Skip to content

v0.2.0-alpha — Array-backed order book

Pre-release
Pre-release

Choose a tag to compare

@emrebulutlar emrebulutlar released this 27 Jun 22:00
cff3fbe

Replaces the preallocated order book with an array-backed, geometry-free engine, and bounds the egress pipeline so matching nodes can't run out of memory under load.

Highlights

  • Array-backed order book — AA tree + pooled doubly-linked FIFO in flat primitive arrays. Geometry-free (no fixed price range/tick), no 64-orders-per-level cap (book-wide tunable pool with a loud BOOK_FULL), zero hot-path allocation. About 3x less memory (668 → 222 MB in-process; long[] 735 → 182 MB live), now proportional to resting orders.
  • Egress hardened — egress buffers were bounded by entry count but not by bytes, so a slow consumer or replaying a large log could exhaust the heap and OOM the matching/consensus threads. Now byte-bounded end to end (~176 MB cap); sheds load with a loud log + OMS reconciliation instead of crashing.
  • Default engine is now array — set MATCH_ENGINE_IMPL=direct to fall back to the preallocated engine.

Validated (single Intel 13700K, 3-node Raft cluster, dev/local)

  • Sub-microsecond matching (p50 ~0.3 µs), flat across load.
  • 281,000 orders/sec at 100% success (limited by the test rig, not the cluster).
  • The 400k orders/sec overload that previously OOM'd two nodes now runs clean, 0 OOM.

Both engines run the determinism corpus and are byte-identical except for the intended 64-cap change. Full diff and commit breakdown in #27.

Tunables: match.engine.book.capacity (default 131072/side), match.egress.buffer.max (default 200k).

Alpha / prerelease.