-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Reduce work done in operator overload syntax classifier. #69866
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
Reduce work done in operator overload syntax classifier. #69866
Conversation
This shows up as 15% of CPU in the code analysis process in a profile provided by DavidW where semantic token requests are performing poorly. Roslyn classification walks down the tree, finding AssignmentExpressionSyntax nodes and performing semantic binding on the nodes (expensive). Two optimizations to short-circuit before performing the binding: 1) Per Cyrus, this operation doesn't need to occur on simple assignments (the most common case of AssignmentExpressionSyntax nodes) 2) Check whether the requested range intersects the location where the classification would actually be reported.
...aces/CSharp/Portable/Classification/SyntaxClassification/OperatorOverloadSyntaxClassifier.cs
Show resolved
Hide resolved
...aces/CSharp/Portable/Classification/SyntaxClassification/OperatorOverloadSyntaxClassifier.cs
Outdated
Show resolved
Hide resolved
...VisualBasic/Portable/Classification/SyntaxClassification/OperatorOverloadSyntaxClassifier.vb
Outdated
Show resolved
Hide resolved
| Dim symbolInfo = semanticModel.GetSymbolInfo(syntax, cancellationToken) | ||
| If TypeOf symbolInfo.Symbol Is IMethodSymbol AndAlso | ||
| DirectCast(symbolInfo.Symbol, IMethodSymbol).MethodKind = MethodKind.UserDefinedOperator Then | ||
| If (operatorSpan.IsEmpty OrElse Not operatorSpan.IntersectsWith(textSpan)) Then |
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.
| If (operatorSpan.IsEmpty OrElse Not operatorSpan.IntersectsWith(textSpan)) Then | |
| If operatorSpan.IsEmpty OrElse Not operatorSpan.IntersectsWith(textSpan) Then |
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.
C# habits die hard
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.
Bah, it doesn't look like this change was pushed before merged. Will create a small PR with just that.

This shows up as 15% of CPU in the code analysis process in a profile provided by DavidW where semantic token requests are performing poorly.
Roslyn classification walks down the tree, finding AssignmentExpressionSyntax nodes and performing semantic binding on the nodes (expensive).
Two optimizations to short-circuit before performing the binding: 1) Per Cyrus, this operation doesn't need to occur on simple assignments (the most common case of AssignmentExpressionSyntax nodes) 2) Check whether the requested range intersects the location where the classification would actually be reported.