adding regex-automata to cargo.toml file reduces performance
vvmikheev opened this issue · 0 comments
vvmikheev commented
Hello.
I have met some weird problems with the latest 1.10.5 regex
release.
After the upgrade I have encountered some serious performance problems with regular expressions compilation.
After hours of debugging I have noticed kinda unexpected behavior - adding regex-automata
crate to Cargo.toml
file somehow affects the regex
performance (makes it several times worse).
MRE:
use std::time::Instant;
use regex::Regex;
fn main() {
let now = Instant::now();
for _ in 0..10000 {
Regex::new("some.regex").unwrap();
}
println!("took {}ms", now.elapsed().as_millis());
}
Cargo.toml file:
[package]
name = "testy"
version = "0.1.0"
edition = "2021"
[dependencies]
regex = "1.10.5"
regex-automata = "0.4.7" # <-- remove this guy to see the difference!
I understand that regex-automata
is in the dependencies of regex
. Moreover - the only thing that is changed in Cargo.lock
file is the list of dependencies of the testy
crate. But on my computer this program takes like 3 second without explicit regex-automata
and 18 seconds with it.