Thanks! Appreciate it. For clarity, this is the corpus I downloaded:
https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.12.5.ta...And I used
fs=(**/*.h)
since including the C files caused the argument list to be too long on my system.
My CPU is a bit dated, but is a i7-6900K @ 3.2 GHz.
My Nim version:
$ nim --version
Nim Compiler Version 1.4.6 [Linux: amd64]
Compiled at 2021-04-26
Copyright (c) 2006-2020 by Andreas Rumpf
active boot switches: -d:release -d:nativeStackTrace
With those caveats, this is what I get on my system:
$ TIMEFMT=$'%*E'
$ repeat 5 time ~/clones/cligen/examples/grl -sburntsushi $fs
0.093
0.079
0.083
0.083
0.082
$ repeat 5 time rg --no-config burntsushi $fs
0.088
0.088
0.086
0.082
0.083
We can somewhat control for substring search by using 'zzzzzzzz'. It won't
control for everything, but it should be close I think.
$ repeat 5 time ~/clones/cligen/examples/grl -szzzzzzzz $fs
0.086
0.073
0.080
0.078
0.075
$ repeat 5 time rg --no-config zzzzzzzz $fs
0.085
0.087
0.084
0.084
0.086
If I run with jobs=1 for both tools, I get:
$ repeat 5 time ~/clones/cligen/examples/grl -j1 -szzzzzzzz $fs
0.204
0.201
0.188
0.214
0.190
$ repeat 5 time rg --no-config -j1 zzzzzzzz $fs
0.261
0.239
0.231
0.226
0.256
Here's where it gets interesting. If I force ripgrep to use memory maps, then I get (first with parallelism, and then without):
$ repeat 5 time rg --no-config --mmap zzzzzzzz $fs
0.399
0.328
0.354
0.343
0.357
$ repeat 5 time rg --no-config --mmap -j1 zzzzzzzz $fs
0.312
0.278
0.280
0.266
0.245
I think on the one hand, I'm confused as to why I can't reproduce your result. But the more interesting thing to me is why ripgrep is so slow when it uses memory maps, but your program is not.
The strace output for ripgrep also shows more syscalls than I would expect, so I'll be investigating that as well.
There are also lots of 'pselect6' syscalls in your program. Do you know what those are from?
Anyway, thanks for the interesting benchmark! Some interesting bits to investigate!