-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Speed up single-value SearchValues<string> candidate verification #108365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Speed up single-value SearchValues<string> candidate verification #108365
Conversation
Tagging subscribers to this area: @dotnet/area-system-memory |
7051ac1
to
bc01b11
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 5 out of 8 changed files in this pull request and generated 1 comment.
Files not reviewed (3)
- src/libraries/System.Private.CoreLib/src/System/Collections/Generic/RandomizedStringEqualityComparer.cs: Evaluated as low risk
- src/libraries/System.Private.CoreLib/src/System/String.cs: Evaluated as low risk
- src/libraries/System.Private.CoreLib/src/System/String.Comparison.cs: Evaluated as low risk
...System.Private.CoreLib/src/System/SearchValues/Strings/SingleStringSearchValuesThreeChars.cs
Show resolved
Hide resolved
...s/System.Private.CoreLib/src/System/SearchValues/Strings/Helpers/StringSearchValuesHelper.cs
Outdated
Show resolved
Hide resolved
...s/System.Private.CoreLib/src/System/SearchValues/Strings/Helpers/StringSearchValuesHelper.cs
Show resolved
Hide resolved
...s/System.Private.CoreLib/src/System/SearchValues/Strings/Helpers/StringSearchValuesHelper.cs
Show resolved
Hide resolved
...s/System.Private.CoreLib/src/System/SearchValues/Strings/Helpers/StringSearchValuesHelper.cs
Show resolved
Hide resolved
...s/System.Private.CoreLib/src/System/SearchValues/Strings/Helpers/StringSearchValuesHelper.cs
Outdated
Show resolved
Hide resolved
39e6787
to
fc28ebe
Compare
@MihuBot benchmark Sherlock https://github.com/MihaZupan/performance/tree/compiled-regex-only -medium |
System.Text.RegularExpressions.Tests.Perf_Regex_Industry_RustLang_Sherlock
|
This PR does 2 related changes to speed up the verification of potential matches:
[9, 16]
chars.We already had groups
[2, 3] [4, 7] [8, ∞]
, this PR changes that to[2, 3] [4, 8] [9, 16] [17, ∞]
.SingleValueState
for more details).These optimizations logically help more the more verifications we must perform.
As such it particularly helps with early matches, or where the anchor selection was poor such that we must rule out many false positives. In benchmarks like SliceSlice, it barely matters since matches are relatively rare.
It also gives us more options in the future to experiment with using fewer anchor characters (e.g. 2 instead of 3), trading higher scanning throughput for more false positive candidates, but where ruling those out is now cheaper.