ripgrep is faster than {grep, ag, git grep, ucg, pt, sift}
Summary
A comprehensive benchmark of ripgrep (rg) against grep, ag, git grep, ucg, pt, and sift across 25 tests shows ripgrep consistently wins or ties on both single-file and directory-wide searches. The article explains the engineering decisions behind ripgrep’s speed - including SIMD-accelerated literal matching, minimal-syscall directory traversal, chase-lev work-stealing parallelism, and deliberately avoiding memory maps for multi-file search. It remains the only tool with full Unicode support that does not impose a significant performance penalty.
Key Insight
- ripgrep beats all tested tools on single-file benchmarks, often by a large margin; on directory-wide searches it ties or narrowly trails git grep on simple patterns but pulls far ahead on complex/Unicode patterns
- Memory maps are slower for searching many small files in parallel but faster for single large files - ripgrep defaults to not using mmap for multi-file search, which is counter-intuitive but measurably correct
- Key speed techniques: uses memchr on a “rare” byte for fast skipping, a SIMD algorithm called Teddy for multi-pattern matching, Aho-Corasick with single-transition-per-byte optimization, and UTF-8 decoding baked into the finite state machine
- .gitignore filtering uses a RegexSet to match multiple globs against a single path at once instead of testing each glob individually
- GNU grep and git grep support Unicode but get dramatically slower when asked to use Unicode-aware case folding or character classes (\w, ); ripgrep maintains near-native speed because Unicode is always on and built into the DFA
- The -u flag levels are a clean UX pattern: -u ignores .gitignore, -uu also searches hidden files, -uuu also searches binary files