PCRE2 mode rg -P
is consistently faster than rg
#2763
-
Going through https://github.com/BurntSushi/ripgrep/blob/master/FAQ.md#why-does-ripgrep-get-slower-when-i-enable-pcre2-regexes, I tried the example:
On this laptop, Here some hopefully more reliable $ hyperfine "rg '^\w{42}$' subtitles2016-sample" "rg -P '^\w{42}$' subtitles2016-sample"
Benchmark 1: rg '^\w{42}$' subtitles2016-sample
Time (mean ± σ): 1.476 s ± 0.039 s [User: 1.444 s, System: 0.032 s]
Range (min … max): 1.400 s … 1.538 s 10 runs
Benchmark 2: rg -P '^\w{42}$' subtitles2016-sample
Time (mean ± σ): 1.213 s ± 0.006 s [User: 1.179 s, System: 0.033 s]
Range (min … max): 1.202 s … 1.223 s 10 runs
Summary
rg -P '^\w{42}$' subtitles2016-sample ran
1.22 ± 0.03 times faster than rg '^\w{42}$' subtitles2016-sample $ hyperfine "rg -P '^\w{42}$' subtitles2016-sample --no-encoding"
Benchmark 1: rg -P '^\w{42}$' subtitles2016-sample --no-encoding
Time (mean ± σ): 1.161 s ± 0.011 s [User: 1.130 s, System: 0.030 s]
Range (min … max): 1.141 s … 1.174 s 10 runs $ hyperfine "rg -U '^\w{42}$' subtitles2016-sample" "rg -P -U '^\w{42}$' subtitles2016-sample"
Benchmark 1: rg -U '^\w{42}$' subtitles2016-sample
Time (mean ± σ): 1.447 s ± 0.048 s [User: 1.411 s, System: 0.036 s]
Range (min … max): 1.362 s … 1.487 s 10 runs
Benchmark 2: rg -P -U '^\w{42}$' subtitles2016-sample
Time (mean ± σ): 942.7 ms ± 6.2 ms [User: 912.8 ms, System: 29.7 ms]
Range (min … max): 936.6 ms … 953.4 ms 10 runs
Summary
rg -P -U '^\w{42}$' subtitles2016-sample ran
1.54 ± 0.05 times faster than rg -U '^\w{42}$' subtitles2016-sample Is this a performance regression of the $ rg --version
ripgrep 14.1.0
features:-simd-accel,+pcre2
simd(compile):+SSE2,-SSSE3,-AVX2
simd(runtime):+SSE2,+SSSE3,+AVX2
PCRE2 10.42 is available (JIT is available) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
On my
PCRE2 has actually gotten a little faster (and is indeed faster than ripgrep's default regex engine here):
But if I hop over to my i7-6900K machine (which is due to be decommissioned Real Soon Now), which is the machine where I likely ran the original benchmarks, then we see a different story here. First, ripgrep's default regex engine:
There's a little variation here, but overall about the same.
So PCRE2 got a nice boost here when I upgraded it from 10.32 to 10.42 in the ripgrep 14 release. It is still not as slow as what was seen in the linked FAQ, but one thing I didn't control for here is the Rust compiler. I built all of the Also, PCRE2 doesn't need transcoding any more as of the ripgrep 14 release because of new APIs they added:
This is also likely contributing to the improved speed. |
Beta Was this translation helpful? Give feedback.
On my
i9-12900K
, there's no meaningful regression in ripgrep's default regex engine for this benchmark:PCRE2 has actually gotten a little faster (and is indeed faste…