A high-performance, low-latency network processing framework for learning and experimenting with High-Frequency Trading (HFT) techniques.
latency/
├── crates/ # Framework crates
│ ├── latency-core/ # Core traits and topology
│ ├── latency-backends/ # Network backends (std, DPDK, RDMA)
│ ├── latency-strategies/ # Batching and backpressure strategies
│ ├── latency-metrics/ # Metrics collection framework
│ ├── latency-bench/ # Benchmarking utilities
│ ├── latency-cli/ # Orchestrator binary (main entry point)
│ └── latency-producer/ # Market data producer daemon
├── consumers/ # Consumer topology binaries
│ └── std-single-threaded/ # Standard library single-threaded consumer
├── scripts/ # Test and utility scripts
└── notes/ # Design documentation
The main entry point that manages the full lifecycle of benchmark runs:
# Run benchmark for 60 seconds (default)
cargo run --package latency-cli -- run --consumer std-single-threaded
# Run benchmark for 10 seconds with specific configuration
cargo run --package latency-cli -- run \
--consumer std-single-threaded \
--duration 10 \
--producer-rate 10000 \
--instruments 0,1,2 \
--consumer-batch 64
# Control producer directly
cargo run --package latency-cli -- producer start
cargo run --package latency-cli -- producer status
cargo run --package latency-cli -- producer stopGenerates artificial market data using random walk + sine wave oscillation:
- 5 Default Instruments: AAPL, GOOGL, MSFT, TSLA, AMZN
- Generic Protocol: Trait-based design (SimpleBinaryProtocol included)
- Configurable Rate: Messages per second
- Control Plane: UDP control socket for START/STOP/STATUS
- Instrument Filtering: Subscribe to subset of instruments
Can be run standalone:
cargo run --package latency-producer -- \
--target 127.0.0.1:5000 \
--rate 10000 \
--instruments 0,1,2 \
--auto-startEach consumer is a separate binary representing a specific topology configuration:
std-single-threaded: Baseline using kernel networking, single-threaded topology- (Future)
dpdk-single-threaded: DPDK backend, single-threaded - (Future)
rdma-single-threaded: RDMA backend, single-threaded - (Future) Multi-threaded topologies
# Run a 5-second benchmark with the std consumer
cargo run --package latency-cli -- run \
--consumer std-single-threaded \
--duration 5 \
--producer-rate 1000
# Or use the test script
./scripts/test_orchestrator.shAll strategies are generic and monomorphized at compile time:
Topology<RxBackend, TxBackend, Processor, ThreadingStrategy, BatchingStrategy, BackpressureStrategy>RX and TX backends can be different (e.g., DPDK RX + RDMA TX) without data copying.
- Threading: Single-threaded, Pipelined (future)
- Batching: Fixed, Adaptive
- Backpressure: Drop, Threshold, Wait
See notes/ directory for detailed design documents:
architectural_tradeoffs.md- Single vs multi-threaded, batching, backpressurezero_cost_strategy_design.md- Generic strategy implementationproject_structure.md- Module organizationexecution_flow.md- Packet processing flow
Kernel networking using Rust std::net for baseline comparison.
Kernel bypass using Intel DPDK for high throughput.
Remote Direct Memory Access for ultra-low latency.
MIT OR Apache-2.0