Base64 encoding and decoding at almost the speed of a memory copy
Authors:
- Wojciech MułaWMWojciech Muła
- Daniel LemireDLDaniel Lemire
Preprint
Abstract
Many common document formats on the Internet are text-only such as email (MIME) and the Web (HTML, JavaScript, JSON and XML). To include images or executable code in these documents, we first encode them as text using base64. Standard base64 encoding uses 64~ASCII characters: both lower and upper case Latin letters, digits and two other symbols. We show how we can encode and decode base64 data at nearly the speed of a memory copy (memcpy) on recent Intel processors, as long as the data does not fit in the first-level (L1) cache. We use the SIMD (Single Instruction Multiple Data) instruction set AVX-512 available on commodity processors. Our implementation generates several times fewer instructions than previous SIMD-accelerated base64 codecs. It is also more versatile, as it can be adapted---even at runtime---to any base64 variant by only changing constants.Keywords
All Related Versions
- Version 1, 2019-10-02, ArXiv
- Published version: Software: Practice and Experience, 50 (2), 89.
This publication has 6 references indexed in Scilit:
- Scalability analysis of AVX-512 extensionsThe Journal of Supercomputing, 2019
- Faster Base64 Encoding and Decoding Using AVX2 InstructionsACM Transactions on the Web, 2018
- SWIMM 2.0: Enhanced Smith–Waterman on Intel’s Multicore and Manycore Architectures Based on AVX-512 Vector ExtensionsInternational Journal of Parallel Programming, 2018
- An Exploration of Serverless Architectures for Information Retrieval2017
- The ARM Scalable Vector ExtensionIEEE Micro, 2017
- Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies1996