Live data from Hacker News

Ripgrep is faster than grep, ag, Git grep, ucg, pt, sift (2016)

blog.burntsushi.net

191–198 of 198 posts

Re: Ripgrep is faster than grep, ag, Git grep, ucg, pt, sift (2016)

#191

And this may still be true in 2023, but the problem is that most of the parallelized grep replacements (e.g. ripgrep, ag, etc.) are SO much faster than grep that the much small speed differences between them doesn't provide much of a basis for differentiating them. I use ag (typically from inside Emacs) on a 900k LOC codebase and it is effectively instantaneous (on a 16 core Ryzen Threadripper 2950X). I just don't ha…

In my experience they are all horribly i/o bound and the search takes as long as files load from disk and that's quite long, after that the difference can't possibly be meaningful. When files are in cache search time is dominated by time it takes me to navigate the file system and write the command, and again performance difference can't possibly be meaningful.

> When files are in cache search time is dominated by time it takes me to navigate the file system and write the command

This suggests your corpora are small. If you have small corpora, then it should be absolutely no surprise that one tool taking 40ms and another taking 20ms will matter for standard interactive usage.

Re: Ripgrep is faster than grep, ag, Git grep, ucg, pt, sift (2016)

#192
post #188

Earlier quoted context omitted.

Small clarification: ack did not and does not respect your gitignore files. I just tried it myself, and indeed it doesn't. And this is consistent with the feature chart maintained by the author of ack: https://beyondgrep.com/feature-comparison/ One practical result of this is that it will mean `ack` will be quite slow when searching typical checkouts of Node.js or Rust projects, because it won't automatically ignore…

You can also pass a flag to git grep to ignore the index (--no-index), which makes it search untracked files as well

I know. That's beside the point of my comment. :-)

Re: Ripgrep is faster than grep, ag, Git grep, ucg, pt, sift (2016)

#193
post #181

Earlier quoted context omitted.

Or `\rg`, which will use the command directly and skip your alias.

Oh, look at that. Nice. Still losing the coloring but you can't have everything.

If you want to win on both counts (no buggy pipes and coloring), and if you're certain of the order, you can use the following:

    rg nokogiri.*linux

Re: Ripgrep is faster than grep, ag, Git grep, ucg, pt, sift (2016)

#194
post #187
post #41

Earlier quoted context omitted.

...which is awesome if you can request/install VS Code but not ripgrep. You can find the rg binary in the VS installation (at least, I can on Windows at my place of employment).

Hello thank you for pointing this out. I hate how slow grep is in Windows :( and I cannot install rg (I have no choice in the OS at work)

What’s the nature of your work so you are not allowed to install software?

Re: Ripgrep is faster than grep, ag, Git grep, ucg, pt, sift (2016)

#196

Earlier quoted context omitted.

Multi-GB log files. Even with LC_ALL=C, grep is painfully slow.

That's probably true - but good Lord, one should probably do something to reduce the size of log files that large.

DB logs can get HUGE. logrotate for them is currently daily. I briefly wanted to tune it to help alleviate the issue, but honestly it didn’t and doesn’t matter, given the infrequency with which they’re directly accessed. No risk of running out of disk space, and the DBAs like them how they are, so meh. There are other things to worry about.

Re: Ripgrep is faster than grep, ag, Git grep, ucg, pt, sift (2016)

#197
post #62
post #3

It's fast indeed. And I can't help keeping promoting the combination with fzf :) For those who want to try it out, this is a Powershell function but the same principle applies in any shell. Does ripgrep then puts fuzzy searching in the resulting files+text on top while showing context in bat: function frg { $result = rg --ignore-case --color=always --line-number --no-heading @Args | fzf --ansi ` --color 'hl:-1:underl…

I wrote a bash version of this: function frg { result=`rg --ignore-case --color=always --line-number --no-heading "$@" | fzf --ansi \ --color 'hl:-1:underline,hl+:-1:underline:reverse' \ --delimiter ':' \ --preview "bat --color=always {1} --theme='Solarized (light)' --highlight-line {2}" \ --preview-window 'up,60%,border-bottom,+{2}+3/3,~3'` file="${result%%:*}" linenumber=`echo "${result}" | cut -d: -f2` if [ ! -z "…

Can you explain what this does and why I should I use this(benefits) please ? Thanks

Re: Ripgrep is faster than grep, ag, Git grep, ucg, pt, sift (2016)

#198
post #194
post #187

Earlier quoted context omitted.

Hello thank you for pointing this out. I hate how slow grep is in Windows :( and I cannot install rg (I have no choice in the OS at work)

What’s the nature of your work so you are not allowed to install software?

I'm not allowed to install arbitrary software, only those that are provided by IT. It is just company policy and I cannot change that.
Post reply on HN