Ripgrep – A new command line search tool
I&#x27;m the author of ag. That was a really good comparison of the different code searching tools. The author did a great job of showing how each tool misbehaved or performed poorly in certain circumstances. He&#x27;s also totally right about defaults mattering.<p>It looks like ripgrep gets most of its speedup on ag by:<p>1. Only supporting DFA-able Rust regexes. I&#x27;d love to use a lighter-weight regex library in ag, but users are accustomed to full PCRE support. Switching would cause me to receive a lot of angry emails. Maybe I&#x27;ll do it anyway. PCRE has some annoying limitations. (For example, it can only search up to 2GB at a time.)<p>2. Not counting line numbers by default. The blog post addresses this, but I think results without line numbers are far less useful; so much so that I&#x27;ve traded away performance in ag. (Note that even if you tell ag not to print line numbers, it still wastes time counting them. The printing code is the result of me merging a lot of PRs that I really shouldn&#x27;t have.)<p>3. Not using mmap(). This is a big one, and I&#x27;m not sure what the deal is here. I just added a --nommap option to ag in master.[1] It&#x27;s a naive implementation, but it benchmarks comparably to the default mmap() behavior. I&#x27;m really hoping there&#x27;s a flag I can pass to mmap() or madvise() that says, &quot;Don&#x27;t worry about all that synchronization stuff. I just want to read these bytes sequentially. I&#x27;m OK with undefined behavior if something else changes the file while I&#x27;m reading it.&quot;<p>The author also points out correctness issues with ag. Ag doesn&#x27;t fully support .gitiginore. It doesn&#x27;t support unicode.  Inverse matching (-v) can be crazy slow. These shortcomings are mostly because I originally wrote ag for myself. If I didn&#x27;t use certain gitignore rules or non-ASCII encodings, I didn&#x27;t write the code to support them.<p>Some expectation management: If you try out ripgrep, don&#x27;t get your hopes up. Unless you&#x27;re searching some really big codebases, you won&#x27;t notice the speed difference. What you will notice, however, are the feature differences. Take a look at <a href="https:&#x2F;&#x2F;github.com&#x2F;BurntSushi&#x2F;ripgrep&#x2F;issues" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;BurntSushi&#x2F;ripgrep&#x2F;issues</a> to get a taste of what&#x27;s missing or broken. It will be some time before all those little details are ironed-out.<p>That said, may the best code searching tool win. :)<p>1. <a href="https:&#x2F;&#x2F;github.com&#x2F;ggreer&#x2F;the_silver_searcher&#x2F;commit&#x2F;bd65e2691d6ce673e026842d7e7d02bc25adfd26" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ggreer&#x2F;the_silver_searcher&#x2F;commit&#x2F;bd65e26...</a>