1
0
mirror of https://github.com/BurntSushi/ripgrep.git synced 2025-04-24 17:12:16 +02:00

regex: tweak DFA settings

This increases the limits a bit for when the regex engine will build and
use a fully compiled DFA. They can faster in some circumstances. For
example, '(?-u)^\w{30,}$' gets a nice speed boost from state
acceleration.

We are also able to remove `regex` proper as a dependency. Wow.
This commit is contained in:
Andrew Gallant 2023-06-20 08:09:23 -04:00
parent 81341702af
commit 04dde9a4eb
3 changed files with 10 additions and 3 deletions

1
Cargo.lock generated
View File

@ -200,7 +200,6 @@ dependencies = [
"bstr",
"grep-matcher",
"log",
"regex",
"regex-automata 0.3.0",
"regex-syntax",
]

View File

@ -18,6 +18,5 @@ aho-corasick = "1.0.2"
bstr = "1.5.0"
grep-matcher = { version = "0.1.6", path = "../matcher" }
log = "0.4.19"
regex = "1.8.3"
regex-automata = { version = "0.3.0" }
regex-automata = "0.3.0"
regex-syntax = "0.7.2"

View File

@ -233,6 +233,15 @@ impl ConfiguredHIR {
let meta = Regex::config()
.utf8_empty(false)
.nfa_size_limit(Some(self.config.size_limit))
// We don't expose a knob for this because the one-pass DFA is
// usually not a perf bottleneck for ripgrep. But we give it some
// extra room than the default.
.onepass_size_limit(Some(10 * (1 << 20)))
// Same deal here. The default limit for full DFAs is VERY small,
// but with ripgrep we can afford to spend a bit more time on
// building them I think.
.dfa_size_limit(Some(10 * (1 << 20)))
.dfa_state_limit(Some(10_000))
.hybrid_cache_capacity(self.config.dfa_size_limit);
Regex::builder()
.configure(meta)