Skip to content

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

@vvmikheev

Description

@vvmikheev

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions