ashvardanian/StringZilla logo

ashvardanian/StringZilla

Free

Up to 100x faster strings for C, C++, CUDA, Python, Rust, Swift, JS, & Go, leveraging NEON, AVX2, AVX-512, SVE, GPGPU, & SWAR to accelerate search, hashing, sorting, edit distances, sketches, and memory ops 🦖

FreeFree tier
Inputs: text
Type
Open Source

About ashvardanian/StringZilla

StringZilla is a high-performance string processing library that leverages SIMD (NEON, AVX2, AVX-512, SVE) and SWAR instructions to accelerate common string operations such as exact and fuzzy matching, hashing, sorting, edit distances, segmentation, tokenization, random string generation, and memory operations. It provides allocation-free lazily-evaluated iterators and claims to be up to 100x faster than traditional libraries like LibC for substring search on Arm, 10–70x faster than ICU for UTF-8 handling, case folding, segmentation, and tokenization, and up to 100x faster than NVIDIA's libraries for on-GPU Levenshtein, Needleman-Wunsch, and Smith-Waterman edit distances. StringZilla supports multiple programming languages including C, C++, CUDA, Python, Rust, Swift, Go, JavaScript, and includes backends for WebAssembly, RISC-V, PowerPC, and LoongArch.

Key Features

SIMD/SWAR-accelerated string operations (NEON, AVX2, AVX-512, SVE, GPGPU, SWAR)
Exact and fuzzy substring matching
Hashing and sorting of strings
Edit distance computation (Levenshtein, Needleman-Wunsch, Smith-Waterman)
String segmentation and tokenization
Random string generation
Allocation-free lazily-evaluated iterators
Multi-language support: C, C++, CUDA, Python, Rust, Swift, Go, JavaScript, Java, C#
Custom backends for WebAssembly, RISC-V, PowerPC, LoongArch
UTF-8 handling and case folding

Pros & Cons

Pros
  • Claims dramatic speedups: 3x faster than LibC for substring search on Arm, 10–70x faster than ICU for UTF-8 operations, up to 100x faster than NVIDIA's libraries for GPU edit distances
  • Portable across architectures with automatic SIMD dispatch and custom backends (x86, ARM, RISC-V, PowerPC, LoongArch, WebAssembly)
  • Provides familiar drop-in replacements for standard library string types in multiple languages
  • Open source with permissive license (MIT) and no external dependencies
  • Includes lazy iterators for memory efficiency
Cons
  • Performance gains depend on hardware SIMD support; may have limited benefit on older CPUs without SIMD extensions
  • Not a drop-in replacement for all string operations; requires code changes to use the library
  • Relatively new and less widely adopted than standard libraries, potentially smaller community and fewer resources

Best For

Accelerating substring search in large text corporaReplacing LibC's string.h and STL's string for performance-critical applicationsHigh-speed UTF-8 processing, segmentation, and tokenizationOn-GPU edit distance calculations for bioinformatics (Levenshtein, NW, SW)Sorting and hashing large sets of stringsFuzzy matching in search engines and data cleaning pipelinesBuilding high-performance database and LLM sandbox environments

FAQ

How can I use StringZilla in my C++ project?
Replace STL's std::string with stringzilla/stringzilla.hpp in C++11 and above. The library provides headers and can be integrated via CMake.
Does StringZilla support UTF-8 encoding?
Yes, StringZilla handles UTF-8 encoded Unicode and provides case folding and segmentation operations that are much faster than ICU.