ripgrep is a line-oriented search tool that recursively searches your current directory for a regex pattern while respecting your gitignore rules. ripgrep has first class support on Windows, macOS and Linux, with binary downloads available for every release. ripgrep is similar to other popular search tools like The Silver Searcher, ack and grep.
Is it really faster than everything else?
Generally, yes. A large number of benchmarks with detailed analysis for each is available on my blog.
Summarizing, ripgrep is fast because:
- It is built on top of Rust's regex engine uses finite automata, SIMD and aggressive literal optimizations to make searching very fast.
- Rust's regex library maintains performance with full Unicode support by building UTF-8 decoding directly into its deterministic finite automaton engine.
- It supports searching with either memory maps or by searching incrementally with an intermediate buffer. The former is better for single files and the latter is better for large directories. ripgrep chooses the best searching strategy for you automatically.
- Applies your ignore patterns in
.gitignorefiles using a
RegexSet. That means a single file path can be matched against multiple glob patterns simultaneously.
- It uses a lock-free parallel recursive directory iterator, courtesy of
This example searches the entire Linux kernel source tree (after running make defconfig && make -j8) for [A-Z]+_SUSPEND, where all matches must be words. Timings were collected on a system with an Intel i7-6900K 3.2 GHz, and ripgrep was compiled with SIMD enabled.
|The Silver Searcher||
|git grep (Unicode)||
|The Platinum Searcher||
Here's another benchmark that disregards gitignore files and searches with a whitelist instead. The corpus is the same as in the previous benchmark, and the flags passed to each command ensure that they are doing equivalent work:
And finally, a straight-up comparison between ripgrep and GNU grep on a single large file (~9.3GB, OpenSubtitles2016.raw.en.gz):
helm-ag with rg
(use-package helm-ag :ensure t :after (helm) :config (setq helm-ag-base-command "rg --color=always --smart-case --line-number --no-heading") )