Skip to content

Conversation

@mavasani
Copy link
Contributor

@mavasani mavasani commented Apr 28, 2023

Closes #67888
Follow-up to #67818

Performance measurements

Summary

  • SyntaxTree analyzers: Decent performance improvements seen in this PR for the syntax analyzers. Note that majority of performance benefit was already fetched from Add FilterSpan API to analyzer contexts #67818, which moved our slowest syntax analyzer (IDE0055 - formatting analyzer) to respect context.FilterSpan

  • SemanticModel analyzers: Pretty significant performance improvements seen in this PR for the semantic model action analyzers. See screenshots below

Performance screenshots info:

  • Left image: Using CodeStyle analyzer package built from main branch
  • Right image: Using CodeStyle analyzer package built from this PR branch

SyntaxTree action analyzers

image

SemanticModel action analyzers

image

All analyzers (excluding SymbolStart analyzers)

image

@ghost ghost added Area-Analyzers untriaged Issues and PRs which have not yet been triaged by a lead labels Apr 28, 2023
{
var semanticModel = _compilation.GetSemanticModel(context.Tree);
var diagnostics = semanticModel.GetSyntaxDiagnostics(cancellationToken: context.CancellationToken);
var diagnostics = semanticModel.GetSyntaxDiagnostics(context.FilterSpan, context.CancellationToken);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only compiler change in this PR

@mavasani mavasani marked this pull request as ready for review April 28, 2023 11:36
@mavasani mavasani requested review from a team as code owners April 28, 2023 11:36
@CyrusNajmabadi
Copy link
Member

So conceptually, i'm 100% behind this. But hte pattern is so common, and so clunky, it would def benefit from some helpers/extensions.

I also think it's worth discussing making the value non-nullable, and just having the span be the full file for the non-lightbulb case. Then the consumption side simplifies a ton.

Copy link
Member

@CyrusNajmabadi CyrusNajmabadi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I'd like @sharwell's thoughts on if FilterSpan should be nullable or not. However, that's def not blocking, and this PR does implement the approved design, so that convo can happen in parallel.

I'm on the fence. I hear the point about the analyzer doing something different if the span is null or not. But that seems equiv to the analyzer doing something different if the span if the full-span of the compilation unit or not.

GIven that everyone who uses the span effectively does so to see what's in it, or do an intersection test, then null doesn't seem useful. But i'm ok either way :)

@mavasani mavasani enabled auto-merge May 1, 2023 05:48
@mavasani mavasani merged commit 193c659 into dotnet:main May 1, 2023
@ghost ghost added this to the Next milestone May 1, 2023
@mavasani mavasani deleted the SpanApiAnalyzers branch May 1, 2023 09:14
@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

Development

Successfully merging this pull request may close these issues.

Move the SyntaxTree and SemanticModel action based analyzers to respect context.FilterSpan

3 participants