ignore,globset: increase pool capacity
Before adoption: this commit came in with the history the project adopted, so no landing records it.
When do matching inside of `ignore` or `globset`, we sometimes need a reusable mutable scratch space for matching. To do this, we use a `Pool` abstraction from `regex-automata` to do this heavy lifting for us. It turns out that this can be a limiting factor in some scenarios when gitignore matching dominates. For example, in my checkout of the Chromium repository: ``` $ hyperfine 'rg-master -j32 --files' 'rg-bigger-pool -j32 --files' 'rg-master -j32 --files --no-ignore' Benchmark 1: rg-master -j32 --files Time (mean ± σ): 156.3 ms ± 5.5 ms [User: 2356.4 ms, System: 380.8 ms] Range (min … max): 147.6 ms … 164.5 ms 19 runs Benchmark 2: rg-bigger-pool -j32 --files Time (mean ± σ): 131.6 ms ± 2.1 ms [User: 1628.2 ms, System: 310.1 ms] Range (min … max): 128.8 ms … 136.3 ms 22 runs Benchmark 3: rg-master -j32 --files --no-ignore Time (mean ± σ): 107.4 ms ± 1.0 ms [User: 664.7 ms, System: 304.7 ms] Range (min … max): 104.9 ms … 109.6 ms 28 runs Summary rg-master -j32 --files --no-ignore ran 1.22 ± 0.02 times faster than rg-bigger-pool -j32 --files 1.45 ± 0.05 times faster than rg-master -j32 --files ``` The `--no-ignore` benchmark is our baseline. It doesn't process gitignore files, so it's quite a bit faster. But with this change, processing gitignore files gets faster than what is currently on master. Specifically, re-running the above without the baseline: ``` $ hyperfine 'rg-master -j32 --files' 'rg-bigger-pool -j32 --files' Benchmark 1: rg-master -j32 --files Time (mean ± σ): 154.1 ms ± 5.1 ms [User: 2287.4 ms, System: 378.2 ms] Range (min … max): 144.1 ms … 163.9 ms 19 runs Benchmark 2: rg-bigger-pool -j32 --files Time (mean ± σ): 131.7 ms ± 2.1 ms [User: 1618.6 ms, System: 314.1 ms] Range (min … max): 128.4 ms … 135.3 ms 22 runs Summary rg-bigger-pool -j32 --files ran 1.17 ± 0.04 times faster than rg-master -j32 --files ``` I've used `-j32` here because this change is best observed as improving the *scaling* properties. (And my system has 32 cores, so it's the best case scenario.) If we just let ripgrep use its default thread heuristic (which caps itself at a lower value), then the improvement here is a bit more modest: ``` $ hyperfine 'rg-master --files' 'rg-bigger-pool --files' Benchmark 1: rg-master --files Time (mean ± σ): 150.0 ms ± 8.5 ms [User: 1139.6 ms, System: 237.7 ms] Range (min … max): 131.1 ms … 162.4 ms 22 runs Benchmark 2: rg-bigger-pool --files Time (mean ± σ): 136.0 ms ± 12.1 ms [User: 1034.4 ms, System: 236.0 ms] Range (min … max): 117.7 ms … 157.6 ms 22 runs Summary rg-bigger-pool --files ran 1.10 ± 0.12 times faster than rg-master --files ``` This improves scaling because the underlying change here now uses a cache line for each available thread instead of limiting itself to a fixed value of `8`. The cost is that ripgrep may use a bit more memory storing cached values per thread.
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
5 files+52 added−35 removed
- other:+52 added−35 removed