Skip to content
/ latency Public

High-performance latency testing framework with pluggable backends (kernel sockets, DPDK, RDMA)

Notifications You must be signed in to change notification settings

serle/latency

Repository files navigation

Latency - Low-Latency Network Framework

A high-performance, low-latency network processing framework for learning and experimenting with High-Frequency Trading (HFT) techniques.

Project Structure

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

Key Components

Orchestrator (latency-cli)

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 stop

Market Data Producer (latency-producer)

Generates 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-start

Consumers

Each 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

Quick Start

# 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.sh

Architecture

Zero-Cost Abstractions

All strategies are generic and monomorphized at compile time:

Topology<RxBackend, TxBackend, Processor, ThreadingStrategy, BatchingStrategy, BackpressureStrategy>

Separate RX/TX Rings

RX and TX backends can be different (e.g., DPDK RX + RDMA TX) without data copying.

Configurable Strategies

  • Threading: Single-threaded, Pipelined (future)
  • Batching: Fixed, Adaptive
  • Backpressure: Drop, Threshold, Wait

Design Documentation

See notes/ directory for detailed design documents:

  • architectural_tradeoffs.md - Single vs multi-threaded, batching, backpressure
  • zero_cost_strategy_design.md - Generic strategy implementation
  • project_structure.md - Module organization
  • execution_flow.md - Packet processing flow

Backends

Standard Library (Baseline) ✅

Kernel networking using Rust std::net for baseline comparison.

DPDK (In Progress)

Kernel bypass using Intel DPDK for high throughput.

RDMA (In Progress)

Remote Direct Memory Access for ultra-low latency.

License

MIT OR Apache-2.0

About

High-performance latency testing framework with pluggable backends (kernel sockets, DPDK, RDMA)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published