Zlib-Rs in Firefox
10 hours ago
- #compression
- #performance
- #Firefox
- Firefox version 151.0.0 now uses zlib-rs for gzip compression and decompression, offering performance and safety improvements.
- Integration of zlib-rs into Firefox required updating tests due to differences in output bytes and length compared to stock zlib, as well as handling symbol prefixes like MOZ_Z_inflate.
- During deployment, crashes occurred due to an Intel Raptor Lake CPU bug triggered by a specific instruction in Huffman coding, which was identified and fixed with a workaround using unsafe code.
- The speedup from zlib-rs is significant, especially on Linux x86_64, with benchmarks showing decompression up to 32.50x faster, though optimizations are ongoing for platforms like aarch64 macOS.
- Despite challenges like the CPU bug and test updates, the transition to zlib-rs is considered successful, with gratitude extended to Mozilla engineers for their integration and debugging efforts.