Skip to content
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

IndexOfAny/ProbablyContains/InitializeProbabilisticMap is showing up on radar #2411

Closed
davkean opened this issue Aug 9, 2017 · 6 comments
Closed
Assignees
Labels
performance Performance-Scenario-Solution-Open This issue affects solution open performance. Priority:2 Work that is important, but not critical for the release triaged
Milestone

Comments

@davkean
Copy link
Member

davkean commented Aug 9, 2017

See: https://github.com/dotnet/corefx/issues/22771

I've looked at 3 large solutions where IndexOfAny usage is showing up on the radar. I initially thought that it maybe caused by Directory.GetFiles/GetDirectories usage (where they check for invalid chars) but looking at this trace: #2348, I see it consuming a lot (25% of CPU) - but very little time spent in GetFiles/GetDirectories.

Check usage of other Path APIs, such as GetExtension which also does a invalid char check - it may be caused by this.

I suspect we should just hand write IndexOfAny checks for known chars.

@davkean
Copy link
Member Author

davkean commented Aug 9, 2017

Feel free to assign this one to me.

@davkean
Copy link
Member Author

davkean commented Sep 19, 2017

I suspect this has to do with http://index/?query=ExpandPropertiesLeaveTyped&rightProject=Microsoft.Build&file=Evaluation%5CExpander.cs&line=933:

                // If there are no substitutions, then just return the string.
                propertyStartIndex = s_invariantCompareInfo.IndexOf(expression, "$(", CompareOptions.Ordinal);
                if (propertyStartIndex == -1)
                {
                    return expression;
                }

@davkean
Copy link
Member Author

davkean commented Sep 19, 2017

I believe these belong together (ProbablyContains/InitializeProbabilisticMap usage is always a broken stack so they aren't grouped):

image

@davkean
Copy link
Member Author

davkean commented Sep 21, 2017

I don't know what the cause of this is, I replaced all usage of IndexOfAny and LastIndexOfAny and it's still showing up on the radar.

@panopticoncentral panopticoncentral added the Performance-Scenario-Solution-Open This issue affects solution open performance. label Mar 25, 2020
@panopticoncentral panopticoncentral added the Priority:2 Work that is important, but not critical for the release label Mar 23, 2021
@ladipro
Copy link
Member

ladipro commented Apr 13, 2021

clr!ProbablyContains
clr!InitializeProbabilisticMap
clr!COMString::IndexOfCharArray

together amount to ~0.4% of evaluation time according to recent @arkalyanms's traces.

ProbablyContains and InitializeProbabilisticMap have broken stacks and IndexOfCharArray (~0.2% of eval time) has many callers with nothing standing out:

image

Based on this I'm inclined to close this unless @davkean remembers the scenario where the excessive cost was observed.

@davkean
Copy link
Member Author

davkean commented Apr 13, 2021

I have seen popup in a few traces recently as much as what caused me to file the original CoreFx bug but the traces are long gone. I will keep an eye out for it and reopen this if you close it if I see it again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Performance-Scenario-Solution-Open This issue affects solution open performance. Priority:2 Work that is important, but not critical for the release triaged
Projects
None yet
Development

No branches or pull requests

5 participants