Linux 7.5 ChaCha optimization delivers 99% speedup on AMD Zen 5 via AVX-512
New AVX-512 optimizations for the ChaCha stream cipher in libcrypto enable 16-block processing, significantly boosting performance on modern x86 CPUs.
Summary
The Linux kernel is preparing to integrate optimized code paths for the ChaCha symmetric stream cipher, slated for the Linux 7.5 release. Developed by StrongSwan contributor Martin Willi, the update introduces a 16-block AVX-512 function within libcrypto to better utilize modern processor architectures.
Previously, AVX-512 implementations were restricted to 256-bit YMM registers to prevent the heavy frequency down-clocking seen on older Intel Skylake-X chips. Because modern Intel and AMD processors no longer suffer these severe clock penalties, the new code can leverage full 512-bit ZMM registers to double data-level parallelism for bulk encryption traffic.
Technical breakdown of ChaCha AVX-512 improvements
- Instruction Set Utilization: The patch introduces a new path that processes 16 blocks per invocation using full 512-bit ZMM registers, compared to the previous 8-block limit of the AVX-512VL path.
- Hardware Targeting: The optimization is gated by X86_FEATURE_PREFER_YMM and is designed specifically for modern architectures that do not trigger significant down-clocking when executing wide vector instructions.
- Performance Benchmarks: Testing on AMD Ryzen AI Max Strix Halo (Zen 5) shows performance gains of up to 99%, while prior-generation AMD Zen 4 hardware using 256-bit paths sees improvements up to 39%.
- Implementation Detail: The developer implemented the change by instantiating a shared block macro a second time at VL=64, with the only difference being the final lane-crossing transpose.
Why it matters
This update provides a massive performance boost for cryptographic workloads, which benefits system administrators and users relying on encrypted network protocols like IPsec or WireGuard. It ensures that high-performance x86 hardware, particularly the latest AMD Zen 5 chips, can fully utilize their vector capabilities for secure data transmission.
What to do
- Update to Linux 7.5 to access the optimized ChaCha AVX-512 code paths.
Original reference: www.phoronix.com →