|
| 1 | +1.9.5 (2023-09-02) |
| 2 | +================== |
| 3 | +This is a patch release that hopefully mostly fixes a performance bug that |
| 4 | +occurs when sharing a regex across multiple threads. |
| 5 | + |
| 6 | +Issue [#934](https://github.com/rust-lang/regex/issues/934) |
| 7 | +explains this in more detail. It is [also noted in the crate |
| 8 | +documentation](https://docs.rs/regex/latest/regex/#sharing-a-regex-across-threads-can-result-in-contention). |
| 9 | +The bug can appear when sharing a regex across multiple threads simultaneously, |
| 10 | +as might be the case when using a regex from a `OnceLock`, `lazy_static` or |
| 11 | +similar primitive. Usually high contention only results when using many threads |
| 12 | +to execute searches on small haystacks. |
| 13 | + |
| 14 | +One can avoid the contention problem entirely through one of two methods. |
| 15 | +The first is to use lower level APIs from `regex-automata` that require passing |
| 16 | +state explicitly, such as [`meta::Regex::search_with`](https://docs.rs/regex-automata/latest/regex_automata/meta/struct.Regex.html#method.search_with). |
| 17 | +The second is to clone a regex and send it to other threads explicitly. This |
| 18 | +will not use any additional memory usage compared to sharing the regex. The |
| 19 | +only downside of this approach is that it may be less convenient, for example, |
| 20 | +it won't work with things like `OnceLock` or `lazy_static` or `once_cell`. |
| 21 | + |
| 22 | +With that said, as of this release, the contention performance problems have |
| 23 | +been greatly reduced. This was achieved by changing the free-list so that it |
| 24 | +was sharded across threads, and that ensuring each sharded mutex occupies a |
| 25 | +single cache line to mitigate false sharing. So while contention may still |
| 26 | +impact performance in some cases, it should be a lot better now. |
| 27 | + |
| 28 | +Because of the changes to how the free-list works, please report any issues you |
| 29 | +find with this release. That not only includes search time regressions but also |
| 30 | +significant regressions in memory usage. Reporting improvements is also welcome |
| 31 | +as well! If possible, provide a reproduction. |
| 32 | + |
| 33 | +Bug fixes: |
| 34 | + |
| 35 | +* [BUG #934](https://github.com/rust-lang/regex/issues/934): |
| 36 | +Fix a performance bug where high contention on a single regex led to massive |
| 37 | +slow downs. |
| 38 | + |
| 39 | + |
1 | 40 | 1.9.4 (2023-08-26)
|
2 | 41 | ==================
|
3 | 42 | This is a patch release that fixes a bug where `RegexSet::is_match(..)` could
|
|
0 commit comments