finds.dev← search

// the find

BurntSushi/memchr

★ 1,573 · Rust · Unlicense · updated Aug 2026

Optimized string search routines for Rust.

memchr provides the single/multi-byte and substring (memmem) search routines that power ripgrep and much of the Rust ecosystem's text-processing stack. It's for anyone who needs fast byte-slice search and doesn't want to hand-roll SIMD dispatch and fallback logic themselves.

The algorithm selection is adaptive rather than one-size-fits-all: Rabin-Karp for tiny haystacks (low construction overhead), frequency-heuristic generic SIMD for small needles, Two-Way with a SIMD prefilter for everything else, with a heuristic that disables the prefilter if it stops paying off. It operates on &[u8] instead of &str, so there's no UTF-8 validation tax that std's str-based search pays. Testing is unusually thorough for a crate this size — hand-written tests, exhaustive branch coverage, quickcheck, cargo-fuzz, and benchmarks that double as correctness checks across x86_64 (SSE2/AVX2), aarch64 (NEON) and wasm32. Runtime CPU feature detection means one binary can use AVX2 when present and fall back to SSE2 or SWAR otherwise, which core's own substring search can't do.

Correctness here rests heavily on hand-written unsafe SIMD per target architecture — auditing it yourself takes real low-level effort, you're mostly trusting the fuzz/property-test suite. The API is intentionally narrow (byte and substring search only), so anything beyond that is still your own code to write. The README's own benchmark section admits std has already started borrowing some of this crate's SSE2 tricks, so part of the current performance gap is a moving target rather than a permanent advantage. There's no changelog or explicit semver policy mentioned beyond the MSRV promise (1.61.0), so tracking what changed release-to-release means reading diffs.

View on GitHub →

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →