https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126274
Bug ID: 126274
Summary: [16/17 Regression] std::regex 2-3x slower since
r16-7193-g158ad5f96954da5fa
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: libstdc++
Assignee: tnfchris at gcc dot gnu.org
Reporter: tnfchris at gcc dot gnu.org
Target Milestone: ---
In GCC 16 the commit r16-7193-g158ad5f96954da5fa24d5c2a91ae92417fb62e20
caused a big regression in performance of regex in libstdc++.
an example benchmark is using the CPP version of the benchmarks
at https://github.com/mariomka/regex-benchmark/
The benchmark uses regex_token_iterator over the input text with these
patterns:
- email: [\w.+-]+@[\w.-]+\.[\w.-]+
- URI: [\w]+:\/\/[^\/\s?#]+[^\s?#]+(?:\?[^\s#]*)?(?:#[^\s]*)?
- IPv4:
(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9])
Where it tests various types of regexpr. "email" has no backtracking so it's
the
simplest NFA possible which we should be able to handle quickly.
"uri" has optional matches and some non capturing groups and "ipv4" adds some
alternative matching to the equation.
The input string is a 6.52 mb test file "input-text.txt"
The regressions of each type of regexpr compared to GCC 15 are:
email: 118.9%
URI: 124.8%
IPv4: 139.8%
So most matches became > 2x slower.