Mozilla has successfully replaced Firefox's aging UDP networking stack with a modern Rust-based implementation, delivering impressive performance gains for HTTP/3 traffic. The project, which took over a year to complete, shows how updating decades-old networking code can unlock significant improvements in web browsing speed.
Massive Performance Gains in CPU-Bound Scenarios
The new implementation delivers remarkable results in testing environments. Firefox now achieves up to 4 Gbps throughput compared to less than 1 Gbps with the old system - a 400% improvement in extreme cases. This boost comes from replacing the outdated NSPR (Netscape Portable Runtime) library with quinn-udp, a modern UDP library built for the Quinn QUIC project.
The performance jump matters because around 20% of Firefox's HTTP traffic now uses HTTP/3, which runs over QUIC and UDP protocols. Every time you load a website using HTTP/3, your browser handles substantial UDP network activity behind the scenes.
Performance Comparison
- Old NSPR system: < 1 Gbps throughput
- New quinn-udp system: Up to 4 Gbps throughput
- Improvement: 400% increase in CPU-bound scenarios
- HTTP/3 traffic: ~20% of Firefox's total HTTP traffic
Modern System Calls Unlock Hidden Potential
The key to these improvements lies in using advanced operating system features that didn't exist when Firefox's original networking code was written. Modern systems offer batching capabilities through APIs like sendmmsg and recvmmsg, which can handle multiple network packets at once instead of processing them individually. Some platforms also support segmentation offloading, where the network card itself handles breaking large data chunks into smaller packets.
However, community discussions reveal that even these impressive gains may leave significant performance on the table. Technical analysis suggests the underlying systems could theoretically handle much higher throughput, pointing to bottlenecks elsewhere in the networking stack.
Technical Features
- Memory Safety: Rust implementation replaces C-based NSPR code
- ECN Support: ~50% of QUIC connections in Firefox Nightly use ECN
- Batching: sendmmsg/recvmmsg for multiple packet processing
- Segmentation Offload: GSO/GRO on Linux, USO/URO on Windows (disabled)
Platform-Specific Challenges Create Headaches
While Linux implementation proceeded smoothly with full support for advanced features, other platforms presented significant obstacles. Windows' UDP Segmentation Offload (USO) feature had to be disabled after causing packet loss and even network driver crashes on some systems. A particularly puzzling bug affected Windows on ARM devices with WSL enabled, where the system couldn't properly determine packet sizes.
macOS brought its own complications despite offering undocumented batch processing APIs called sendmmsg_nocopy and recvmmsg_nocopy. Mozilla ultimately decided against using these features in production due to concerns about Apple potentially removing them without notice.
Android proved especially challenging, with Firefox still supporting Android 5 devices that are over 10 years old. The ancient platform requires workarounds for security filters and lacks support for modern networking features, forcing developers to maintain compatibility with severely outdated systems.
Platform Support Status
- Linux: Full GSO/GRO support enabled
- Windows: USO disabled due to packet loss and driver crashes
- macOS: Undocumented batch APIs available but not used in production
- Android: Limited support, maintains compatibility with Android 5 (10+ years old)
Security and Future Benefits
Beyond raw performance, the Rust-based implementation provides memory safety advantages over the previous C-based code. The new system also enables Explicit Congestion Notification (ECN) support across all major platforms, with Firefox Nightly showing about 50% of QUIC connections now using ECN.
The project demonstrates both the potential and challenges of modernizing browser infrastructure. While the performance improvements are substantial, the experience highlights how platform inconsistencies and legacy support requirements can complicate even straightforward optimizations.
Technical note: QUIC is a modern transport protocol designed to improve web performance, while UDP (User Datagram Protocol) is the underlying network protocol that QUIC uses for data transmission.
Reference: Fast UDP I/O for Firefox in Rust
