why does adding regex-automata
to Cargo.toml
increase Regex::new
compilation times?
#1208
-
Hello. After the upgrade I have encountered some serious performance problems with regular expressions compilation. MRE:
Cargo.toml file:
I understand that |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
It happens because The |
Beta Was this translation helpful? Give feedback.
It happens because
regex
andregex-automata
do not have the same set of default features.regex-automata
, in particular, hasdfa-build
anddfa-search
enabled by default. But forregex
, those features only get enabled whenperf-dfa-full
is enabled, and that's specifically not enabled by default for precisely the reason you've run into.The
perf-dfa-full
feature causesregex
to try and use a fully determinized DFA in some cases. It has pretty harsh limits on when it attempts this to avoid making regex compile times even worse, but even building a small DFA is expensive. However, it can open up new optimization opportunities, which is why it's a thing. But in general, the trade off isn't rea…