Repository navigation
v2.4.0
What's Changed
Algorithms
- Shift-Or / BNDM algorithm — New bit-parallel search for patterns 2–8 bytes. Uses a 64-bit state machine with backward nondeterministic DAWG matching (BNDM). Up to 2–3× faster than Boyer-Moore for short patterns on modern CPUs.
- Two-Way string matching — New O(n+m) worst-case scalar fallback based on Crochemore & Perrin (1991), the same algorithm used by glibc's
memmem. Replaces Boyer-Moore-Horspool as the default fallback for patterns where SIMD is unavailable. - New
--algo bndmand--algo twooptions to manually force the new algorithms.
Performance
- NEON 32-byte processing — The ARM64/Apple Silicon NEON path now processes 32 bytes per iteration (2× 16-byte registers) instead of 16, doubling throughput on Apple Silicon.
- Fast word-char lookup table — A precomputed 256-byte table replaces
isalnum()calls in the hot-pathis_word_char()function, eliminating function-call overhead and locale-dependence. - Double-distance prefetching — Streaming workloads now prefetch at both 512-byte and 1024-byte distances (
PREFETCH_DISTANCE_FAR) for better cache line utilization. - MADV_HUGEPAGE on Linux — Large files (>64 MB) now request transparent huge pages via
madvise(MADV_HUGEPAGE)when available, reducing TLB pressure.
Algorithm Selection
- Patterns 2–8 bytes now use BNDM (Shift-Or) by default (except
-cmode with 2–3 byte case-insensitive patterns, which stay onmemchr_short). - Patterns 9+ bytes fall back to Two-Way instead of Boyer-Moore-Horspool, guaranteeing O(n+m) worst-case time.
- KMP is now reserved only for short (<12 bytes) repetitive patterns where its O(n) guarantee beats Two-Way's period-based skipping.
Docs & Metadata
- Version bumped to
2.4.0across source, README badge, Makefile header, and--helpoutput. - README updated with the new algorithms and
--algooptions.
Validation
- 179 tests passing (169 unit + 10 directory) with zero compiler warnings (
-Werror). - CI passed on both
mainbranch andv2.4.0tag. - Platform binaries attached:
krep-linux-x86_64.tar.gzandkrep-macos-arm64.tar.gz.
Full Changelog: v2.3.0...v2.4.0