|
BetaTrader
A HFT Eco-System
|
The exchange_routing module manages the concurrent topology of the exchange. It implements the "Single-Writer" pattern by partitioning instruments across dedicated worker threads.
To achieve massive throughput, the exchange does not use a single global mutex. Instead, every instrument (e.g., EURUSD) is assigned to a specific Partition. Each partition has its own lock-free command queue and a dedicated thread, ensuring that matching for one symbol never blocks matching for another.
Partition container lifecycle.WorkerThread event loop.Command interface for New, Modify, and Cancel operations.| Component | Description |
|---|---|
**Partition** | A logical silo of execution. Owns all state (Book, OrderManager) for its assigned instruments. |
**WorkerThread** | A high-priority system thread pinned (optionally) to a CPU core to drain the command queue. |
**Command** | The common payload format used to move intentions from the networking gateway into the matching engine. |
exchange_matching or exchange_state for a given instrument.WorkerThread can switch to a busy-wait (spin) strategy to minimize context-switch latency.