-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Vectorize string.IndexOf(..., StringComparison.Ordinal) #21076
Vectorize string.IndexOf(..., StringComparison.Ordinal) #21076
Conversation
| // TODO: Instead of this method could we just have upstack code call IndexOfOrdinal with ignoreCase = false? | ||
| private static unsafe int FastIndexOfString(string source, string target, int startIndex, int sourceCount, int targetCount, bool findLastIndex) | ||
| // TODO: Instead of this method could we just have upstack code call LastIndexOfOrdinal with ignoreCase = false? | ||
| private static unsafe int FastLastIndexOfString(string source, string target, int startIndex, int sourceCount, int targetCount) |
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.
Just removed the forward index, last index is still handled here. Ignoring whitespace shows removal more clearly https://github.com/dotnet/coreclr/pull/21076/files?w=1
|
OSX10.12 infra issue: xunit/xunit#1855 |
|
@dotnet-bot test OSX10.12 x64 Checked Innerloop Build and Test please |
src/System.Private.CoreLib/shared/System/MemoryExtensions.Fast.cs
Outdated
Show resolved
Hide resolved
|
@dotnet-bot test OSX10.12 x64 Checked Innerloop Build and Test please |
|
OSX Fail |
|
@dotnet-bot test OSX10.12 x64 Checked Innerloop Build and Test please |
|
OSX Fail |
|
@dotnet-bot test OSX10.12 x64 Checked Innerloop Build and Test please |
src/System.Private.CoreLib/shared/System/Globalization/CompareInfo.Unix.cs
Outdated
Show resolved
Hide resolved
|
I think OSX CI is generally broken |
src/System.Private.CoreLib/shared/System/Globalization/CompareInfo.Windows.cs
Outdated
Show resolved
Hide resolved
src/System.Private.CoreLib/shared/System/Globalization/CompareInfo.Windows.cs
Show resolved
Hide resolved
|
CC @dotnet/dnceng for OSX leg failures |
src/System.Private.CoreLib/shared/System/Globalization/CompareInfo.Windows.cs
Outdated
Show resolved
Hide resolved
src/System.Private.CoreLib/shared/System/Globalization/CompareInfo.Windows.cs
Outdated
Show resolved
Hide resolved
|
I assume there already are test cases checking for all of the edge cases we could hit here? |
|
@benaadams @tarekgh : note that running out of disk space on an OSX machine does not make OSX CI generally broken since after finishing their current Jenkins agent job these machines will in most cases (except when jusssssst enough cleanup happens after the agent finishes) will not take more work. In the retry case, the machine its running on currently still has 18 GB free space and will hopefully succeed. Jenkins in general rarely cleans up workspaces, so it's a constant battle to clean up these machines. |
|
|
||
| // Found the first element of "value". See if the tail matches. | ||
| if (SequenceEqual( | ||
| ref Unsafe.As<char, byte>(ref Unsafe.Add(ref searchSpace, index + 1)), |
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.
Is it ever possible for index to be Int32.MaxValue, causing this addition to integer overflow? I think the answer is no (because IndexOf should never return that value) but am having trouble convincing myself of this.
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.
Rearranged to avoid overflow
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.
Also the byte version
src/System.Private.CoreLib/shared/System/Globalization/CompareInfo.Windows.cs
Outdated
Show resolved
Hide resolved
2252666 to
66b681d
Compare
src/System.Private.CoreLib/shared/System/Globalization/CompareInfo.Windows.cs
Outdated
Show resolved
Hide resolved
src/System.Private.CoreLib/shared/System/Globalization/CompareInfo.cs
Outdated
Show resolved
Hide resolved
|
Thank you! |
…lr#21076) * Vectorize string.IndexOf(..., StringComparison.Ordinal) * Merge two IndexOf(..., int* matchLengthPtr) * fix 2 callers expect value.Length == 0 to be tested first 3rd caller ReplaceCore doesn't allow a value.Length == 0 so moving it first is ok Commit migrated from dotnet/coreclr@b526aff
x 2.5 times faster at position 0
x 11.2 times faster at position 1024
For
https://gist.github.com/benaadams/177d989fea110f51fab14cd708239852
Contributes to https://github.com/dotnet/coreclr/issues/19672
/cc @jkotas, @krwq, @tarekgh