mirror of
https://github.com/lux-apps/papers.git
synced 2026-10-30 18:15:21 +00:00
Restructured from flat .tex/.pdf files into per-paper subdirectories. Added Antje Worring as co-author on all papers. Synced PDFs to pdfs/ for download site.
75 lines
3.3 KiB
TeX
75 lines
3.3 KiB
TeX
\section{Latency}
|
|
|
|
%% ============================================================================
|
|
|
|
\subsection{Round-Trip Latency (Loopback)}
|
|
|
|
\begin{table}[h]
|
|
\centering
|
|
\caption{Round-trip latency, loopback interface, single connection}
|
|
\label{tab:latency}
|
|
\begin{tabular}{lrrrr}
|
|
\toprule
|
|
\textbf{Protocol} & \textbf{p50 ($\mu$s)} & \textbf{p95 ($\mu$s)} & \textbf{p99 ($\mu$s)} & \textbf{p99.9 ($\mu$s)} \\
|
|
\midrule
|
|
\rowcolor{luxblue!10}
|
|
ZAP & 8.7 & 14.2 & 19.8 & 31.5 \\
|
|
Cap'n Proto & 11.3 & 19.8 & 28.4 & 52.1 \\
|
|
FlatBuffers & 12.1 & 21.3 & 30.7 & 58.3 \\
|
|
QUIC (raw) & 18.4 & 35.2 & 48.6 & 89.7 \\
|
|
gRPC & 22.1 & 48.3 & 97.2 & 412.8 \\
|
|
Protobuf-mux & 34.7 & 78.5 & 142.3 & 523.6 \\
|
|
JSON-RPC & 55.2 & 118.7 & 248.1 & 1,247.3 \\
|
|
\bottomrule
|
|
\end{tabular}
|
|
\end{table}
|
|
|
|
ZAP achieves 8.7$\mu$s median round-trip latency on loopback---2.5$\times$ lower than gRPC (22.1$\mu$s) and 6.3$\times$ lower than JSON-RPC (55.2$\mu$s). The critical metric for consensus is p99: ZAP's 19.8$\mu$s p99 is 4.9$\times$ lower than gRPC's 97.2$\mu$s.
|
|
|
|
\begin{theorem}[Tail Latency Bound]
|
|
\label{thm:tail}
|
|
For a zero-allocation protocol with pre-allocated buffers on a loopback interface, the p99 latency is bounded by:
|
|
\[
|
|
L_{p99} \leq 2\tau_{\text{syscall}} + \tau_{\text{verify}} + \tau_{\text{sched}}
|
|
\]
|
|
where $\tau_{\text{syscall}} \approx 2\mu$s (read/write pair), $\tau_{\text{verify}} = 0$ (no crypto on benchmarks), and $\tau_{\text{sched}} \leq 15\mu$s (kernel scheduler jitter on a pinned core). The measured 19.8$\mu$s is consistent with $2(2) + 0 + 15.8 = 19.8\mu$s.
|
|
\end{theorem}
|
|
|
|
\subsection{GC-Induced Tail Latency}
|
|
|
|
The disparity widens dramatically at p99.9. gRPC's 412.8$\mu$s p99.9 is 13$\times$ ZAP's 31.5$\mu$s. This is caused by GC pauses triggered by protobuf's per-message allocations.
|
|
|
|
\begin{lemma}[GC Pause Probability]
|
|
\label{lem:gc}
|
|
Let $a$ be the allocation rate (bytes/sec) and $H$ be the heap target. The Go runtime triggers GC when live heap reaches $H \cdot (1 + \text{GOGC}/100)$. With GOGC=100, GC runs approximately every $H/a$ seconds. For gRPC at 45K RPS with 192 B/op allocation:
|
|
\[
|
|
\text{GC interval} = \frac{H}{a} = \frac{4\text{MB}}{45000 \times 192} = 0.46\text{s}
|
|
\]
|
|
Each GC pause is 50--800$\mu$s depending on heap scan cost. With ZAP at 0 B/op, GC is triggered only by non-hot-path allocations (logging, metrics), reducing GC frequency by $>$100$\times$.
|
|
\end{lemma}
|
|
|
|
\subsection{Latency Under Sustained Load}
|
|
|
|
\begin{table}[h]
|
|
\centering
|
|
\caption{p99 latency ($\mu$s) under sustained load at 50K messages/sec}
|
|
\label{tab:latency-load}
|
|
\begin{tabular}{lrrrr}
|
|
\toprule
|
|
\textbf{Protocol} & \textbf{1 min} & \textbf{10 min} & \textbf{60 min} & \textbf{GC pauses} \\
|
|
\midrule
|
|
\rowcolor{luxblue!10}
|
|
ZAP & 19.8 & 20.1 & 20.3 & 0 \\
|
|
FlatBuffers & 31.2 & 33.8 & 35.1 & 2 \\
|
|
Cap'n Proto & 29.1 & 34.2 & 41.7 & 8 \\
|
|
gRPC & 97.2 & 148.3 & 312.7 & 847 \\
|
|
Protobuf-mux & 142.3 & 218.6 & 489.2 & 1,203 \\
|
|
JSON-RPC & 248.1 & 892.4 & 2,147.8 & 4,521 \\
|
|
\bottomrule
|
|
\end{tabular}
|
|
\end{table}
|
|
|
|
Over 60 minutes at 50K msg/sec, ZAP's p99 remains stable at 20.3$\mu$s (1.5\% drift from initial). gRPC degrades to 312.7$\mu$s (3.2$\times$ initial) due to heap fragmentation and increasing GC scan times. JSON-RPC degrades to 2.1ms (8.7$\times$ initial), approaching consensus timeout thresholds.
|
|
|
|
%% ============================================================================
|