Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

adding regex-automata to cargo.toml file reduces performance #1207

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
vvmikheev opened this issue Jun 24, 2024 · 0 comments
Closed

adding regex-automata to cargo.toml file reduces performance #1207

vvmikheev opened this issue Jun 24, 2024 · 0 comments

Comments

@vvmikheev
Copy link

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.

@rust-lang rust-lang locked and limited conversation to collaborators Jun 24, 2024
@BurntSushi BurntSushi converted this issue into discussion #1208 Jun 24, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant