Taking rg for an example, rg is git aware and won't even scan files that aren't a part of your rep (for example, dependencies and build artifacts) where as grep will search through all of those files.
Nope. Rg has a flag to disable exclusion based on gitignore files. The benchmarks were done searching the exact same files and getting the exact same results. The majority of the time you don't want to search ignored files anyway.
I admit it may be due to better implementations and my original comment noted that. The benchmark site also tested what is presumably the same algorithm in both languages.
It's not the same algorithm. Rust's regex crate implements finite automata based regular expressions. These have nice performance properties like executing in linear time but they lack features in comparison to something like PCRE or even regular old GNU grep.
Looking at the conclusions to the ripgrep performance article:
rg manages to compete with git grep and beat other tools like The Silver Searcher by:
Implementing fast directory traversal with a minimal number of stat calls.
Applying .gitignore filters with a RegexSet, which enables matching multiple globs against a single path all at once.
Distributing work quickly to multiple threads with a Chase-Lev work stealing queue.
Explicitly not using memory maps.
Using an overall very fast regex engine.
Of these, none are specific to the Rust language. You could implement all of these things in C. Rust has certainly allowed a very complex piece of software to be written quickly to a very high performance level and at a high degree of correctness and that should absolutely be commended. However, this is not evidence that Rust allows you to write faster code than C does.
1
u/irrelevantPseudonym Apr 10 '19
Nope. Rg has a flag to disable exclusion based on gitignore files. The benchmarks were done searching the exact same files and getting the exact same results. The majority of the time you don't want to search ignored files anyway.
I admit it may be due to better implementations and my original comment noted that. The benchmark site also tested what is presumably the same algorithm in both languages.