roslyn: Very slow IntelliSense on relatively small code base

image

image

I’m not sure which process should be looked into for this case, devenv or ServiceHub.RoslynCodeAnalysisService.

GetSymbolInfo is commonly showing up as expensive in both:

  • ServiceHub.RoslynCodeAnalysisService: GetSymbolInfo is called by NameSyntaxClassifier.AddClassification
  • devenv: GetSymbolInfo is called by CSharpSyntaxContext.CreateContext and CSharpTypeInferenceService+TypeInferrer.InferTypesWorker_DoNotCallDirectly.

If I clear GroupPats and FoldPats (which I read somewhere, but I don’t understand what they actually do), I see GetUseSiteInfo starts showing up.

image

image

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 5
  • Comments: 33 (32 by maintainers)

Most upvoted comments

FWIW, it looks like there are a number of CompletionProvider instances invoked by CompletionService.GetCompletionsAsync when typing . in the method, and the CompletionProvider instances bind the modified method at least 4 times with distinct SemanticModel instances, so there is no sharing of BoundLambda instances between those cases. Two of the CompletionProvider instances are from Roslyn:

  • Microsoft.CodeAnalysis.CSharp.Completion.Providers.KeywordCompletionProvider
  • Microsoft.CodeAnalysis.CSharp.Completion.Providers.SymbolCompletionProvider

If those two CompletionProvider instances could share a SemanticModel, at least when not using a SpeculativeSemanticModel, that might increase Intellisense perf slightly.

cc @CyrusNajmabadi

It looks like typing . in the Visual Studio editor results in binding the method body 10 times. It’s not clear how many of those method body bindings are required for displaying the completion list though.

@jeromelaban I think it’s about shadowing, even if the code doesn’t have any methods that shadow others from base. It’s an algorithm that runs as part of the overload resolution:

https://github.com/dotnet/roslyn/blob/ef625f3b960594fcb3f902af88ad7c90df656516/src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/OverloadResolution.cs#L250-L257

@cston Re-sent.