Skip to main content
QUICK REVIEW

[Paper Review] Transcoding Billions of Unicode Characters per Second with SIMD Instructions

Daniel Lemire, Wojciech Muła|arXiv (Cornell University)|Sep 21, 2021
Algorithms and Data CompressionComputer Science13 references9 citations
TL;DR

This paper presents highly optimized SIMD-accelerated algorithms for transcoding Unicode text between UTF-8 and UTF-16 formats, achieving over 4 billion characters per second on modern x64 and ARM processors. By leveraging AVX2 and SSE instructions with compact lookup tables and bit manipulation, the authors achieve up to 4× speedup over conventional libraries like ICU, even for mixed-content and emoji-rich data, while using only ~11 KB of table space.

ABSTRACT

In software, text is often represented using Unicode formats (UTF-8 and UTF-16). We frequently have to convert text from one format to the other, a process called transcoding. Popular transcoding functions are slower than state-of-the-art disks and networks. These transcoding functions make little use of the single-instruction-multiple-data (SIMD) instructions available on commodity processors. By designing transcoding algorithms for SIMD instructions, we multiply the speed of transcoding on current systems (x64 and ARM). To ensure reproducibility, we make our software freely available as an open source library.

Motivation & Objective

  • To address the performance bottleneck in Unicode transcoding, which limits system throughput despite advances in network and disk speeds.
  • To design SIMD-optimized algorithms that efficiently transcode between UTF-8 and UTF-16 with full validation.
  • To minimize memory usage and code bloat while maximizing throughput across diverse workloads, including non-ASCII and emoji-rich text.
  • To provide a practical, portable, and open-source implementation compatible with x64, ARM, and POWER architectures.

Proposed method

  • Designing vectorized algorithms using AVX2 and SSE instructions to process multiple bytes or 16-bit words in parallel.
  • Using compact 16-byte lookup tables (totaling ~11 KB) to permute and extract UTF-8/UTF-16 data based on character length patterns.
  • Applying bit manipulation and mask operations to extract and reassemble code points from multi-byte sequences efficiently.
  • Implementing a hybrid approach that detects and handles ASCII sequences with fast paths to avoid table lookups.
  • Using SIMD permutation instructions (e.g., pshufb) to rearrange bytes within 128-bit registers based on precomputed indices.
  • Validating input sequences during transcoding using vectorized checks for byte continuation and lead byte patterns.

Experimental results

Research questions

  • RQ1Can SIMD instructions be effectively used to accelerate full Unicode transcoding between UTF-8 and UTF-16, including edge cases like emojis and multi-byte characters?
  • RQ2What is the minimal memory footprint required to achieve high-throughput Unicode transcoding using SIMD?
  • RQ3How does the performance of SIMD-based transcoding compare to state-of-the-art non-SIMD libraries like ICU and LLVM?
  • RQ4Can the same algorithm achieve high performance across diverse platforms (x64, ARM, POWER) without platform-specific tuning?
  • RQ5Is it possible to achieve high throughput without relying on large lookup tables or complex data alignment?

Key findings

  • The proposed SIMD-based transcoding functions achieve over 4 billion characters per second on modern x64 and ARM processors, significantly outperforming ICU and LLVM.
  • The UTF-8 to UTF-16 transcoder is faster than the reverse direction, with performance ratios up to 2:1, due to the higher complexity of variable-length UTF-8 encoding.
  • The method uses only ~11 KB of lookup tables, substantially less than prior approaches like Inoue et al. (105 KB) or Gatilov’s utf8lut (2 MB), without sacrificing performance.
  • The implementation is portable and compiles to a binary library under 50 KB, supporting Linux, macOS, Windows, and multiple CPU architectures.
  • The library outperforms existing SIMD solutions like utf8sse4 and u8u16 by reducing instruction count and achieving higher throughput.
  • The approach maintains high performance even on mixed-content data, including emojis and non-BMP characters, unlike many competing techniques.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.