The UDP Renaissance: Why Firefox Ditched Its 90s-Era Network Stack

Approximately 20% of Firefox's HTTP traffic now flows over HTTP/3 atop QUIC—a UDP-based protocol. This surge exposed limitations in Firefox's Network Security Services Portable Runtime (NSPR), whose PR_SendTo/PR_RecvFrom APIs date back to the Netscape era. Faced with dated single-datagram I/O, Mozilla engineers embarked on a mission: rebuild Firefox's UDP stack using modern system calls while shifting to memory-safe Rust.

"The 'N' in NSPR stands for Netscape—that tells you everything about its vintage," notes the engineering team. "Modern OSes offer batched I/O and segmentation offloading, but we couldn't leverage them."

Three Paths to Faster UDP: Evolution of Datagram Handling

1️⃣ Single Datagram (Legacy)

  • Classic sendto/recvfrom per datagram
  • High per-packet overhead: 1 syscall per <1500 bytes

2️⃣ Batched Datagrams (Modern)

  • Linux's sendmmsg/recvmmsg processes multiple datagrams per syscall
  • Reduces context-switch overhead for high-throughput scenarios

3️⃣ Segmented Offloading (Cutting-Edge)

  • GSO/GRO (Linux) or USO/URO (Windows) submit one large datagram
  • NIC or kernel splits/combines packets automatically
  • Minimizes syscalls while maximizing hardware acceleration
graph TD
  A[Firefox] -->|Large Segmented Datagram| B(OS Kernel)
  B -->|Segmentation Offload| C[Network Interface]
  C -->|Multiple Packets| D[Internet]

Platform Wars: The Good, Bad, and Ugly of Cross-OS Optimization

🪟 Windows: Powerful Features, Fragile Foundations

  • USO/URO promised 4x throughput but caused crashes
  • ARM64 devices with WSL enabled broke URO packet reassembly
  • Status: USO/URO disabled in production; Microsoft engagement ongoing

🐧 Linux: The Gold Standard

  • Full GSO/GRO support delivered consistent 300-400% gains
  • Quinn-udp prioritizes GSO over sendmmsg due to per-connection sockets
  • Seccomp sandboxing adapted smoothly

🍎 macOS: Hidden Gems

  • No native segmentation offloading
  • Undocumented sendmsg_x/recvmsg_x enable batching
  • Status: Experimental due to stability concerns

🤖 Android: Fragmentation Challenges

  • x86 devices required socketcall workarounds
  • ECN bits caused errors on API ≤25
  • Ancient kernel support (Android 5+) complicated GSO adoption

Tangible Wins: Speed, Safety, and Future-Proofing

  • 4Gbps+ throughput in CPU-bound benchmarks (vs. <1Gbps previously)
  • Rust implementation eliminates memory safety risks in critical I/O path
  • ECN support enabled on 50%+ of QUIC paths (telemetry data)
  • Open-source synergy: Quinn-udp accelerated development while Firefox contributions improved upstream

The Unfinished Symphony

While segmentation offloading now rockets data on Linux, Windows's USO/URO remains grounded. As QUIC adoption grows, pressure mounts on OS and driver vendors to stabilize advanced UDP features. For Firefox users, the silent revolution means faster browsing—with Rust ensuring the foundation won't crumble like Netscape's did decades ago.

Source: Max Inden - Fast UDP I/O in Firefox