Benchmarks
benchmarks/ contains three comparable harnesses:
benchmarks/rs-netty: rs-netty echo servers and clients.benchmarks/tokio: bare Tokio echo servers and clients.benchmarks/netty: Java Netty echo servers and clients.
They align the wire protocols:
line: TCP line echo,payload + "\n".len: TCP length-field echo,u32be length + payload.udp: UDP datagram echo.
Directional Snapshot
Benchmark results are directional snapshots, not general performance promises. Throughput, latency, and RSS depend on host, NIC, OS, JVM warmup, TCP settings, payload shape, connection count, in-flight count, loopback usage, and other factors.
The table in the README comes from one local non-loopback run of this repository’s benchmark harness. It is useful for understanding approximate scale and relative trends, not as a guarantee in arbitrary production environments.
Runner
Main entry point:
python3 benchmarks/run.py \
--impls rs-netty tokio netty \
--protocols line len udp \
--connections 100 \
--messages 1000000 \
--payload 128 \
--in-flight 16 \
--output-dir benchmarks/results
The runner:
- auto-selects a non-loopback local IPv4 address, or uses
--host. - rejects
localhost,127.0.0.1, and::1. - builds selected implementations.
- starts the server and samples server RSS.
- runs the matching client.
- parses the
RESULT ...line. - writes CSV, logs, and charts.
Output includes:
results.csv*.server.out.log*.server.err.log*.client.out.log*.client.err.logthroughput.pngp99_latency.pngserver_memory.pnglatency_percentiles.png
With --profile cpu, macOS sample(1) also produces server samples and profile summaries.
Smoke Run
Quick smoke run:
python3 benchmarks/run.py \
--impls rs-netty tokio \
--protocols len \
--connections 2 \
--messages 100 \
--payload 32 \
--in-flight 4
Including Netty requires Maven and a JDK. The runner builds Rust harnesses in release mode automatically.
rs-netty Harness Notes
benchmarks/rs-netty/src/main.rs contains:
server-rs-line/server-rs-line-string:LineCodec+Handler<String>.server-rs-line-bytes: customBytesLineCodec+Handler<Bytes>.server-rs-line-sync: line echo variant that awaitswrite_and_flush.server-rs-len: custom composite codec usingLengthFieldBasedFrameDecoderandLengthFieldPrepender.server-rs-udp:Utf8DatagramCodec+DatagramHandler<String>.
Clients use bare Tokio connections, record latency percentiles, and print a uniform RESULT line.