采用SIMD指令的快速容错Base64解码
Fast Forgiving Base64 Decoding with SIMD Instructions
AI总结:
针对现有SIMD Base64解码器无法处理含空白字符输入的问题,提出面向块的容错解码算法,实现多架构支持,在AMD Zen 5上达94 GB/s,集成后Uint8Array.fromBase64吞吐量最高提升6倍,已被主流浏览器和JS运行时采用。
摘要:
在互联网中,我们使用Base64格式将二进制数据(如图像或加密密钥)表示为文本。ES2026 JavaScript标准遵循WHATWG容错Base64规则,要求解码器忽略ASCII空白字符,同时拒绝其他非字母字符。现有的SIMD Base64解码器假设输入无空白字符。我们提出一种面向块的解码算法,可在SIMD循环内移除空白字符:对干净的64字符块直接解码,对包含可忽略字符的块则压缩至小型栈缓冲区。我们提供了x64(从SSSE3到AVX-512 VBMI2)、ARM NEON和LoongArch的实现。我们的C++解码器在最新AMD Zen 5处理器上达到了94 GB/s的速度。在2025年,将我们的解码器集成后,Uint8Array.fromBase64的吞吐量相比2019年的实现提升了最高6倍。该实现已被主流浏览器和JavaScript运行时采用。
英文摘要:
On the Internet, we use the Base64 format to represent binary data (e.g., images or cryptographic keys) as text. The ES2026 JavaScript standard, following the WHATWG forgiving-base64 rules, requires decoders to ignore ASCII whitespace while rejecting other non-alphabet characters. Prior SIMD Base64 decoders assume whitespace-free input. We present a block-oriented decoding algorithm that removes whitespace inside the SIMD loop: clean 64-character blocks are decoded directly, while blocks with ignorable characters are compacted into a small stack buffer. We provide implementations for x64 (SSSE3 through AVX-512 VBMI2), ARM NEON, and LoongArch. Our C++ decoder reaches up to 94 GB/s on recent AMD Zen 5 processors. In Node 25, integration of our decoder raises Uint8Array.fromBase64 throughput by up to 6x compared with Node 19. The implementation has been adopted by major browsers and JavaScript runtimes.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。