4 ms·
> [...] because ripgrep tends to skip things you don't care about anyway. so you bring the trick #1 from the grep author to a new level: > #1 trick: GNU grep
by tlamponi 8y ago
> [...] because ripgrep tends to skip things you don't care about anyway.
so you bring the trick #1 from the grep author to a new level:
> #1 trick: GNU grep is fast because it AVOIDS LOOKING AT EVERY INPUT BYTE.
You stop looking at entire files, which can avoid a lot of bytes to go through.
Also parallelisms surely helps with a lot of files, or big ones really big ones which could be processed in chunks.
- burntsushi 8y agoNo, that's a bad trick to rely on for speed these days. GNU grep's speed comes from using memchr in its skip loop. Skipping bytes is only going to matter when the thing you're searching for is longer. For short needles, there isn't much opportunity for skipping, so it's better to say inside a vectorized routine like memchr (which, for glibc, is written in Assembly on most platforms).