Revert "Simplify RegexInterpreter (#124628)"#126221
Merged
danmoseley merged 1 commit intodotnet:mainfrom Mar 28, 2026
Merged
Conversation
This reverts commit f194942.
Contributor
|
Tagging subscribers to this area: @dotnet/area-system-text-regularexpressions |
Member
Author
|
Verified locally that this recovers the regression. |
Contributor
There was a problem hiding this comment.
Pull request overview
Reverts the RegexInterpreter.MatchString change from #124628 that replaced the per-character literal match loop with StartsWith/EndsWith, addressing a measured interpreter performance regression on Linux/arm64 for short literal alternations (e.g., Leipzig benchmarks).
Changes:
- Restore the original tight per-character comparison loop in
RegexInterpreter.MatchString. - Avoid
Slice+StartsWith/EndsWithoverhead in hot paths where literals are short and invoked millions of times.
Member
Member
Author
|
Yes, complete git revert. |
This was referenced Mar 28, 2026
Open
stephentoub
approved these changes
Mar 28, 2026
Member
Author
|
/ba-g unrelated |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Revert "Simplify RegexInterpreter (#124628)"
This reverts commit f194942 from #124628.
Closes #126156
#124628 replaced the char-by-char loop in
RegexInterpreter.MatchStringwithStartsWith/EndsWith. This caused a 7-11% regression on arm64 (AmpereUbuntu) forPerf_Regex_Industry_Leipzigpatterns that exerciseMatchStringheavily via alternation:.{0,2}(Tom|Sawyer|Huckleberry|Finn)None: 5.01s to 5.56s (1.11x).{2,4}(Tom|Sawyer|Huckleberry|Finn)None: 5.16s to 5.51s (1.07x)These patterns call
MatchStringmillions of times with short strings (3-11 chars: "Tom", "Finn", "Sawyer", "Huckleberry") whereSlice+StartsWith+SequenceEqualdispatch overhead exceeds the original tight loop cost, with no SIMD benefit at those lengths.The MihuBot x64 results for the original PR showed the same patterns regressing at 1.03-1.04x, but this was overlooked during review.