Skip to content
This repository has been archived by the owner on Nov 1, 2020. It is now read-only.

Move String.Searching.cs to shared CoreLib partition #4673

Merged
merged 2 commits into from
Oct 4, 2017
Merged

Move String.Searching.cs to shared CoreLib partition #4673

merged 2 commits into from
Oct 4, 2017

Conversation

jkotas
Copy link
Member

@jkotas jkotas commented Oct 4, 2017

No description provided.

@@ -335,6 +333,10 @@ public int IndexOf(String value, int startIndex, int count, StringComparison com
return CultureInfo.InvariantCulture.CompareInfo.IndexOf(this, value, startIndex, count, CompareOptions.Ordinal);

case StringComparison.OrdinalIgnoreCase:
#if CORECLR
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this CORECLR-specific because of IsAscii?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it was CORECLR-specific because of IsAscii - I went over all diffs between the files to make sure there is nothing falling through cracks.

After taking a closer look, the IsAscii path is actually hurting performance on CoreCLR. I have removed it. E.g. "Hello".IndexOf("ll", StringComparison.OrdinalIgnoreCase); is about 2x faster with the IsAscii check removed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ouch. Is that true across the board with the IsAscii check, or just this specific case? Presumably IsAscii needs to enumerate the whole string to check the chars and then caches the result, so I could see it actually slowing things down in situations where we're only going to be operating on a string once (which is probably fairly common), and helping in cases where we'd operate on it multiple times, assuming the "fast path" is actually faster.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, it is how IsAscii check works. It was always a questionable "optimization". It maybe worth going over the remaining places in CoreCLR where it is used and see whether it is helping anywhere: https://github.com/dotnet/coreclr/issues/14320

Also, it has to cache the IsAscii bit on a sync block which complicates runtime internals - it is why it does not exist in CoreRT.

@jkotas
Copy link
Member Author

jkotas commented Oct 4, 2017

cc @bbowyersmyth

@jkotas jkotas merged commit 72a64d7 into dotnet:master Oct 4, 2017
dotnet-bot pushed a commit to dotnet/coreclr that referenced this pull request Oct 4, 2017
)

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
jkotas added a commit to jkotas/coreclr that referenced this pull request Oct 4, 2017
)

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
jkotas added a commit to dotnet/coreclr that referenced this pull request Oct 4, 2017
)

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
@jkotas jkotas deleted the string-searching branch October 4, 2017 23:31
dotnet-bot pushed a commit to dotnet/corefx that referenced this pull request Jan 13, 2018
)

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
Signed-off-by: dotnet-bot-corefx-mirror <dotnet-bot@microsoft.com>
dotnet-bot pushed a commit to dotnet/corefx that referenced this pull request Jan 13, 2018
)

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
Signed-off-by: dotnet-bot-corefx-mirror <dotnet-bot@microsoft.com>
safern pushed a commit to dotnet/corefx that referenced this pull request Jan 16, 2018
)

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
Signed-off-by: dotnet-bot-corefx-mirror <dotnet-bot@microsoft.com>
safern pushed a commit to dotnet/corefx that referenced this pull request Jan 16, 2018
)

Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
Signed-off-by: dotnet-bot-corefx-mirror <dotnet-bot@microsoft.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants