gh-91404: Improve re performance#91495
Conversation
|
Nice speedup. I wonder how much of the speedup would be achieved by just moving
How easy would it be to apply the changes that move |
Sorry, something went wrong.
@brandtbucher, could you show results with disabled computed gotos? Only regex-related benchmarks are interesting. |
Sorry, something went wrong.
|
With only computed gotos: With only new locals: Combined: For I think we should keep both. |
Sorry, something went wrong.
|
Excellent! Before merging, could you compare it with 3.10? If there is the same difference, it would be worth to add a note about speed up 10-20% in the NEWS and What's New files. |
Sorry, something went wrong.
This is a backport of the upstream 3.11 improvement: python/cpython#91495 I only backported the ctx->pattern -> pattern and ctx->ptr -> ptr part because using computed goto actually decreased perf slightly on the opt build.
This makes a few performance improvements in
sre_lib.h:ctxpointer (ctx->patternandctx->ptr) are lifted into local variables.(The diff looks gnarly, but everything inside the main switch is just mechanical replacements to support these two changes. It's not really that bad.)
It yields nice improvements on all of the expected benchmarks, and a 1% improvement overall:
Maybe
rewon't be slower in 3.11 after all! 🙃