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

Add caching for symbols retrieved by TokenTypeAnalyzer and SymbolReferenceAnalyzer #4217

Closed
costin-zaharia-sonarsource opened this issue Apr 9, 2021 · 2 comments
Labels
Area: C# C# rules related issues. Area: VB.NET VB.NET rules related issues. Type: Performance It takes too long.

Comments

@costin-zaharia-sonarsource
Copy link
Member

Both TokenTypeAnalyzer and SymbolReferenceAnalyzer retrieve the same symbols and by caching them we will reduce the processor time used by these 2 rules in half. I did a POC and for the repro I've added I have the following results:

from:

    31.131   28      SonarAnalyzer.Rules.CSharp.TokenTypeAnalyzer
    31.065   28      SonarAnalyzer.Rules.CSharp.SymbolReferenceAnalyzer

to:

    29.596   41      SonarAnalyzer.Rules.CSharp.TokenTypeAnalyzer
     0.019   <1      SonarAnalyzer.Rules.CSharp.SymbolReferenceAnalyzer
@martin-strecker-sonarsource
Copy link
Contributor

@costin-zaharia-sonarsource I think this is outdated and can be closed:

  • TokenTypeAnalyzer queries way less symbol info than before (<10% of what it used to query).
  • Registration of the analyzer changed to "RegisterSemanticModel" which gives the same model for both analyzers and the model does caching on its own.

@costin-zaharia-sonarsource
Copy link
Member Author

Thanks, indeed this has been changed in the meantime and the issue is no longer up to date.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: C# C# rules related issues. Area: VB.NET VB.NET rules related issues. Type: Performance It takes too long.
Projects
None yet
Development

No branches or pull requests

3 participants