Measured overhead
Measured on loopback withshareclick bench --encrypted:
~6.5 µs one-way
Transport overhead: serialize + seal + socket + open + deserialize.
~20 ns
Extra cost of encryption (ChaCha20-Poly1305 on tiny packets).
~6 µs one-way means our code is not the bottleneck. On a real LAN,
end-to-end input lag is dominated by the network RTT (~0.2–1 ms) and OS event
injection — not ShareClick.
Why it’s this fast
UDP for input, TCP for bulk
UDP for input, TCP for bulk
A dropped mouse move is irrelevant a millisecond later, so UDP avoids
head-of-line blocking. The fast path never waits on retransmits of the slow
path. See Decision #1.
Dedicated blocking socket, not async
Dedicated blocking socket, not async
An async runtime adds scheduler jitter on the hot path. A dedicated thread
with a blocking socket has the most predictable latency —
transport.rs is
intentionally synchronous. See Decision #3.Per-tick event coalescing
Per-tick event coalescing
High mouse polling rates (1000+ Hz) would flood the network and cause
“jumpiness” when polling exceeds display refresh. Coalescing a tick’s events
into one packet fixes both. See Decision #6.
Allocation-light, lock-free hot path
Allocation-light, lock-free hot path
transport.rs uses immutable cipher state and no per-packet locks or
allocations, precisely to avoid scheduler jitter.Run the benchmark yourself
No OS permissions needed — the benchmark runs entirely on loopback:Next
Architecture
The full dual-channel design behind these numbers.