Skip to content

v2.4.0

Choose a tag to compare

@github-actions github-actions released this 19 May 07:07
· 6 commits to main since this release

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 bndm and --algo two options 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-path is_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 -c mode with 2–3 byte case-insensitive patterns, which stay on memchr_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.0 across source, README badge, Makefile header, and --help output.
  • README updated with the new algorithms and --algo options.

Validation

  • 179 tests passing (169 unit + 10 directory) with zero compiler warnings (-Werror).
  • CI passed on both main branch and v2.4.0 tag.
  • Platform binaries attached: krep-linux-x86_64.tar.gz and krep-macos-arm64.tar.gz.

Full Changelog: v2.3.0...v2.4.0