Back to Nautilus Trader

Network WebSocket Benchmarks

crates/network/benches/BENCHMARKS.md

1.231.05.9 KB
Original Source

Network WebSocket Benchmarks

Numbers measured 2026-07-29. The tables report the median of three back‑to‑back runs on the same host.

Refresh these numbers after a substantive WebSocket transport change or dependency upgrade. Absolute numbers vary by machine; only same‑machine deltas are meaningful.

Environment

ItemValue
CPUAMD Ryzen Threadripper 9980X, 64 cores, 128 threads, one socket
CPU topologySMT enabled, one NUMA node, 256 MiB L3 cache
OSUbuntu 24.04.4 LTS, x86_64
KernelLinux 7.0.0-28-generic
Repository revision1c555c143f73bd6e66c8960561b0c46493533660 plus this benchmark patch
Rustrustc 1.97.1, LLVM 22.1.6
Cargocargo 1.97.1
Profilebench-lto: release, fat LTO, one codegen unit, full debug info

Measurement controls

  • CPU governor: performance on all 128 logical CPUs.
  • ASLR: disabled per process with setarch "$(uname -m)" -R.
  • CPU scheduling: SMT and boost enabled; benchmark thread not pinned.
  • Latency sampling: 1,000 warmup messages, then 50,000 measured messages.
  • Throughput sampling: Criterion default warmup and 100 samples.
  • Aggregation: median of three back‑to‑back runs per table cell.

How to reproduce

bash
sudo cpupower frequency-set -g performance
for run in 1 2 3; do
    CARGO_BUILD_JOBS=16 setarch "$(uname -m)" -R \
        cargo bench -p nautilus-network --profile bench-lto \
        --bench websocket_transport -- --save-baseline "ws_run_$run" --noplot
    CARGO_BUILD_JOBS=16 NAUTILUS_WS_LATENCY_MESSAGES=50000 \
        setarch "$(uname -m)" -R \
        cargo bench -p nautilus-network --profile bench-lto \
        --bench websocket_latency
done
sudo cpupower frequency-set -g powersave

For policy and the general noise‑reduction recipe, see BENCHMARKING.md at the repository root.

Methodology

The benchmarks compare tokio-tungstenite 0.30.0 and sockudo-ws 2.0.1 in the same binary and measurement session.

  • Both use established, uncompressed streams over identical 1 MiB in‑memory Tokio duplex transports and a current‑thread runtime through Sink and Stream.
  • Sockudo enables simd, fastrand, tokio-runtime, and rustls-webpki-roots; auto_ping and idle_timeout are disabled to isolate frame transport.
  • Throughput processes 10,000 text messages per Criterion iteration.
  • Round‑trip latency spans client send through echo receive.
  • One‑way burst latency timestamps each binary message from a continuous sender and includes in‑memory queueing and receiver backpressure.
  • Each p99.9 value covers 50 observations per run; it is useful but noisier than p50, p95, or p99.

The benchmark excludes DNS, TCP connect, TLS, HTTP upgrade, kernel network I/O, and external network latency. It also excludes Compio, sockudo's native split‑stream driver, compression, and keepalive traffic.

Round-trip text latency

Lower is better. Values are microseconds.

PayloadLibraryp50p95p99p99.9
64 Btokio-tungstenite 0.30.01.9532.8443.1655.298
64 Bsockudo-ws 2.0.10.5310.5610.5810.661
512 Btokio-tungstenite 0.30.02.0332.9853.3056.149
512 Bsockudo-ws 2.0.10.6010.6310.6510.721
4,096 Btokio-tungstenite 0.30.02.4443.6663.8367.000
4,096 Bsockudo-ws 2.0.10.8720.9911.0421.272

Across these payloads, sockudo-ws 2.0.1 reduces p99 latency by 73-82% relative to tokio-tungstenite 0.30.0.

One-way binary burst latency

Lower is better. Values are microseconds and include queueing within the in‑memory transport.

PayloadLibraryp50p95p99p99.9
64 Btokio-tungstenite 0.30.09.64511.54814.07221.783
64 Bsockudo-ws 2.0.18.99410.31514.01221.152
512 Btokio-tungstenite 0.30.010.89712.24917.64723.015
512 Bsockudo-ws 2.0.110.22511.90815.05322.835
4,096 Btokio-tungstenite 0.30.023.89728.18336.35650.777
4,096 Bsockudo-ws 2.0.119.28922.65427.97340.031

At 512 B, sockudo-ws 2.0.1 reduces p99 burst latency by 15% relative to tokio-tungstenite 0.30.0.

Text throughput

Higher is better. Values are millions of messages per second.

WorkloadPayloadtokio-tungstenite 0.30.0sockudo-ws 2.0.1
Receive64 B8.6709.868
Receive512 B7.1878.504
Receive4,096 B2.7513.798
Send64 B7.8249.036
Send512 B6.4007.207
Send4,096 B2.2382.622
Round trip64 B0.5372.084
Round trip512 B0.5301.852
Round trip4,096 B0.4341.156

At 512 B, sockudo-ws 2.0.1 processes 18% more receives, 13% more sends, and 250% more round trips than tokio-tungstenite 0.30.0.