2 ms·
As others have mentioned, Rust's regex library has been fuzz tested. Most of the bugs have been fixed. There are a couple outstanding that I hope to get to soon
by burntsushi 10y ago
As others have mentioned, Rust's regex library has been fuzz tested. Most of the bugs have been fixed. There are a couple outstanding that I hope to get to soon. None of them have been unsafe memory bugs. :-)
Benchmarking is a bit mirkier. The benchmark game has already been linked, but the regex-dna benchmark can't really be used to judge the overall performance of regex engines. It's not that the regex-dna benchmark is bad on its own, but rather, it's not enough. You need more coverage. For example, regex engines with aggressive literal optimizations will do very well on regex-dna.
Rust's regex library does have a benchmark harness that compares it to many other popular regex engines: PCRE1 w/ JIT, PCRE2 w/ JIT, RE2, Tcl's engine and Oniguruma. In general, Rust's regex engine is competitive with PCRE{1,2} and RE2, but does quite a bit better than both Tcl and Oniguruma. I haven't added Boost to this harness, but in theory it would be relatively easy. You can see how I did it for RE2[1].
Unfortunately, the set of benchmarks in the harness---while probably better than any other benchmark I've seen---has two major problems with it:
1. It is biased. I wrote most of the benchmarks and I'm not terribly familiar with the types of optimizations performed by sophisticated backtracking engines. Moreover, many of the benchmarks were added to measure optimizations I added to Rust's regex engine, so there will naturally be more benchmarks where Rust does well.
2. The benchmarks themselves lack analysis. Microbenchmarks are too hard to interpret using numbers alone. Someone needs to do the work to explain the results. I've always intended to do this, but it is a gargantuan task.
I've just updated the repo to contain the benchmark results as of today[2]. The most interesting comparison is PCRE2, which is quite fast.[3] Most of the interesting benchmarks are defined in sherlock.rs[4], which also contains some Rust specific notes.
Another source of benchmarks is my blog post on ripgrep[5]. This isn't really a benchmark for regex engines, but rather, a benchmark for line oriented search tools. Nevertheless, it is a collection of data points.
[1] - https://github.com/rust-lang/regex/blob/master/bench/src/ffi/re2.rs https://github.com/rust-lang/regex/blob/master/bench/src/ffi...
[2] - https://github.com/rust-lang/regex/tree/master/bench/log/05 https://github.com/rust-lang/regex/tree/master/bench/log/05
[3] - https://github.com/rust-lang/regex/blob/master/bench/log/05/pcre2-vs-rust https://github.com/rust-lang/regex/blob/master/bench/log/05/...
[4] - https://github.com/rust-lang/regex/blob/master/bench/src/sherlock.rs https://github.com/rust-lang/regex/blob/master/bench/src/she...
[5] - http://blog.burntsushi.net/ripgrep/ http://blog.burntsushi.net/ripgrep/