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 FilterSpan API to analyzer contexts #67818

Merged
merged 4 commits into from
Apr 26, 2023
Merged

Conversation

mavasani
Copy link
Contributor

@mavasani mavasani commented Apr 14, 2023

Closes #67257

  • Add FilterSpan public API to SemanticModelAnalysisContext and SyntaxTreeAnalysisContext types to allow analyzers to optimize diagnostic computation for lightbulb code path.
  • Add span based public API overloads to CompilationWithAnalyzers to compute syntax diagnostics
  • Updates our most expensive syntax tree action based analyzer (formatting analyzer - IDE0055) to respect this filter span.

Performance measurements with this change

I wrote a custom standalone tool based on Roslyn NuGet packages that directly loads the compilation and invokes CompilationWithAnalyzers.GetAnalysisResultAsync(tree, ...) API with and without filterSpan. I am seeing pretty significant performance improvement for the formatting analyzer after this change, see screenshot below. Left side is time to compute full file formatting diagnostics, right side is time to compute span-only formatting diagnostics.
FilterSpan

Closes dotnet#67257
Add FilterSpan public API to SemanticModelAnalysisContext and SyntaxTreeAnalysisContext types to allow analyzers to optimize diagnostic computation for lightbulb code path.
@mavasani mavasani marked this pull request as ready for review April 20, 2023 06:05
@mavasani mavasani requested review from a team as code owners April 20, 2023 06:05
@mavasani
Copy link
Contributor Author

@dotnet/roslyn-compiler ping for reviews - this is a simple change which gives us very good performance improvement for lightbulb.

@mavasani
Copy link
Contributor Author

Thanks @cston. @dotnet/roslyn-compiler for an additional review.

@mavasani
Copy link
Contributor Author

Thank you @jjonescz!

@mavasani mavasani merged commit dc47e84 into dotnet:main Apr 26, 2023
@mavasani mavasani deleted the SpanApi branch April 26, 2023 13:35
@ghost ghost added this to the Next milestone Apr 26, 2023
mavasani added a commit to mavasani/roslyn that referenced this pull request Apr 28, 2023
mavasani added a commit to mavasani/roslyn that referenced this pull request Apr 28, 2023
mavasani added a commit to mavasani/roslyn that referenced this pull request Apr 28, 2023
mavasani added a commit to mavasani/roslyn that referenced this pull request Apr 28, 2023
mavasani added a commit to mavasani/roslyn that referenced this pull request Apr 28, 2023
@mavasani mavasani added the Performance-Scenario-Diagnostics This issue affects diagnostics computation performance for lightbulb, background analysis, tagger. label May 1, 2023
@Cosifne Cosifne modified the milestones: Next, 17.7 P2 May 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Analyzers Performance-Scenario-Diagnostics This issue affects diagnostics computation performance for lightbulb, background analysis, tagger. untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
4 participants