“Now this is the programming I like, low-level assembly optimisation of long operations, none of this web development rubbish”
Base64 encoding and decoding at almost the speed of a memory copy
用 AVX-512 让 Base64 编解码速度逼近 memcpy
论文展示如何利用 AVX-512 SIMD 指令集,在较新的 Intel 处理器上让 Base64 编码和解码在数据不能放进 L1 缓存时接近内存拷贝(memcpy)的速度。实现生成的指令数比以往的 SIMD 加速 Base64 编解码器少好几倍,并且只需改动常量就能(甚至在运行时)适配任何 Base64 变体。
输入里没有保留下来的评论摘录,无法判断 HN 上的人为什么反复提它;只知道它在 2019 至 2026 年间被 4 个人在 3 个月里提及。
学习路径
读这篇之前,按顺序读书架上的 2 篇 · 参考文献来自 OpenAlex,顺序和要点由 Claude Code 排出这条路径先看同一作者用 AVX2 加速 Base64 的前作,再看 simdjson 里的 SIMD 解析思路,最后读用 AVX-512 把 Base64 做到接近内存拷贝速度。
- 1
目标论文是这篇 AVX2 Base64 工作的直接后续,先建立 SIMD 编解码的基本做法。
读用向量指令把字节重排为 6 位索引再查表翻译的编码流程,以及解码时的校验方式。
- 2
同一作者的 SIMD 解析工作,展示如何用向量指令处理字节流并避免分支。
读只看如何用 SIMD 批量分类字符、减少分支的思路;JSON 结构解析部分可略读。
- 3Base64 encoding and decoding at almost the speed of a memory copy
目标论文:用 AVX-512 指令把 Base64 编解码速度推到接近 memcpy。
读AVX-512 下的字节重排与查表指令、与 AVX2 版本的差别,以及数据不在 L1 缓存时速度逼近内存拷贝的评测。
HN 书评
没有评论直接链到它;下面是它被提交的讨论串里回复最多的评论(不计入统计)“Why is that an achievement? Isn't it so that during a memory copy the CPU is basically idling because memory is so much slower than the CPU? Weren't that hundreds of instructions per memory access? So instead of having it wait it can also do computations (just standard instructions). Or is base64 computationally so heavy that it cannot fit into the "gaps"…”
“If base64 decoding speed makes a difference in your application, you should be considering why you are transmitting data in base64, a neat hack from the 1970's, which is non-human-readable, wastes 30% of the network bandwidth, kills compression, wastes RAM, is typically hard to random-access, and is generally a bad idea all round.”
- Base64 encoding and decoding at almost the speed of a memory copy ↗matt_d · 2019-11-05 · 5 分
- Base64 encoding and decoding at almost the speed of a memory copy ↗beefhash · 2019-11-06 · 344 分
- Base64 encoding and decoding at almost the speed of a memory copy (2019) ↗frontfor · 2025-04-27 · 4 分
- Base64 encoding and decoding at almost the speed of a memory copy ↗tosh · 2026-05-17 · 1 分