Repository navigation
Possible slowdown of regex searching in 3.11 #91404
Description
Activity
The 3 regular expression benchmarks in the pyperformance suite, regex_v8, regex_effbot and regex_dna show slowdowns between 3% and 10%.
Looking at the stats, nothing seems wrong with specialization or the memory optimizations.
Which strongly suggests a regression in the sre module itself, but I can't say so for certain.
- added3.11only security fixesonly security fixesperformancePerformance or resource usagePerformance or resource usage
on Apr 7, 2022 Could you give the two versions? I will do a git bisect.
I tested 356997c~1 and 356997c [1], msvc2022 non-pgo release build:
# regex_dna ###
an +- std dev: 151 ms +- 1 ms -> 152 ms +- 1 ms: 1.01x slower
t significant# regex_effbot ###
an +- std dev: 2.47 ms +- 0.01 ms -> 2.46 ms +- 0.02 ms: 1.00x faster
t significant# regex_v8 ###
an +- std dev: 21.7 ms +- 0.1 ms -> 22.4 ms +- 0.1 ms: 1.03x slower
gnificant (t=-30.82)Possibly related to the new atomic grouping support from #76163?
Possibly related to the new atomic grouping support from #76163?
It seems not likely.
I will do some benchmarks for this issue, more information (version/platform) is welcome.Not sure how we're supposed to be linking issues to PRs yet, but check out #91495.
Leaving this open, since it may still be worth exploring where the prior 3.10-to-3.11 slowdown came from.
Chromium build effectively hangs with Python 3.11 due to re slowdown.
generate_about_tracing_contentstakes 6 seconds on Python 3.10, and I killed it after 1 hour on Python 3.11.Reduced example:
re.findall(r'(?:(?:/[^\n]*)?\n)*/', '../utils/common":3}],15:[function(t,e,a){"use strict";e.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],"/":[function(t,e,a){"use strict";var i={};(0,t("./lib/utils/common").assign)(i,t("./lib/deflate"),t("./lib/inflate"),t("./lib/zlib/constants")),e.exports=i},{"./lib/deflate":1,"./lib/inflate":2,"./lib/utils/common":3,"./lib/zlib/constants":6}]},{},[])("/")});\n')takes about 0.02 seconds on Python 3.10, and 8.6 seconds on Python 3.11.
Full example: slow.tar.gz
I can confirm that the PR fixes the performance regression in @Hello71 's reproducer - thanks @sweeneyde for tracking that down.
- added a commit that references this issue
on Jun 26, 2022
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields: