software engineering19 min read

Case-folding source code at memory speed in GitHub's Blackbird engine

  • casefold
  • Blackbird
  • ICU
  • CPython

AI Summary

GitHub engineers optimized the case folding operation in their Blackbird code search engine, achieving over 45 GiB/s on a single core. By removing early-exit branches and utilizing a branch-free vectorizable loop, they sped up the ASCII fast path. They also developed a byte-space arithmetic method for non-ASCII characters that avoids UTF-8 decoding and encoding overhead.

Key Takeaways

  • The Rust crate is open-sourced as casefold.
  • Byte-space arithmetic requires valid, shortest-form UTF-8 input.
  • Branchless scalar code can be a pessimization unless paired with vectorization.

Why it matters

High-performance text processing is critical for large-scale code search engines. This article demonstrates how eliminating branches and avoiding UTF-8 decode/encode cycles can maximize CPU utilization and operate at memory bandwidth limits.

Conversation0

What would you add from your experience?

Checking your session…

Every good conversation starts with one perspective.