Skip to content

[Async lightbulb performance] Move suppression fixes to 'Low' priority bucket#56959

Merged
mavasani merged 5 commits intodotnet:mainfrom
mavasani:AsyncLightBulb_LowPri
Dec 1, 2021
Merged

[Async lightbulb performance] Move suppression fixes to 'Low' priority bucket#56959
mavasani merged 5 commits intodotnet:mainfrom
mavasani:AsyncLightBulb_LowPri

Conversation

@mavasani
Copy link
Copy Markdown
Contributor

@mavasani mavasani commented Oct 5, 2021

Addresses second item in #56843

Prior to this change, all the analyzers that are not high-pri are added to the normal priority bucket and executed at once. This PR further breaks down the normal priority bucket into two buckets as follow:

  1. Normal: Analyzers that produce at least one fixable diagnostic, i.e. have a corresponding code fixer.
  2. Low: Analyzers without any fixable diagnostics, i.e. have no corresponding code fixer. These diagnostics will only have Suppression/Configuration quick actions, which are lower priority and always show up at the bottom of the light bulb.

This new bucketing allows us to reduce the number of analyzers that are executed in the Normal priority bucket and hence generate all the non-suppression/configuration code fixes faster in async light bulb.

@mavasani mavasani added this to the 17.1 milestone Oct 5, 2021
@mavasani mavasani requested review from a team, CyrusNajmabadi and sharwell October 5, 2021 11:49
@mavasani mavasani marked this pull request as draft October 6, 2021 03:23
@mavasani mavasani force-pushed the AsyncLightBulb_LowPri branch 5 times, most recently from a715801 to cdb9ac6 Compare October 8, 2021 08:27
@mavasani
Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@mavasani mavasani force-pushed the AsyncLightBulb_LowPri branch from cdb9ac6 to f2e3b8f Compare October 29, 2021 08:50
@mavasani mavasani force-pushed the AsyncLightBulb_LowPri branch from 1236b74 to 928ccb4 Compare November 8, 2021 08:25
Addresses second item in dotnet#56843

Prior to this change, all the analyzers that are not high-pri are added to the normal priority bucket and executed at once. This PR further breaks down the normal priority bucket into two buckets as follow:

1. `Normal`: Analyzers that produce at least one fixable diagnostic, i.e. have a corresponding code fixer.
2. `Low`: Analyzers without any fixable diagnostics, i.e. have no corresponding code fixer. These diagnostics will only have Suppression/Configuration quick actions, which are lower priority and always show up at the bottom of the light bulb.

This new bucketing allows us to reduce the number of analyzers that are executed in the Normal priority bucket and hence generate all the non-suppression/configuration code fixes faster in async light bulb.
@mavasani mavasani force-pushed the AsyncLightBulb_LowPri branch from d4ee79c to 0a2f5d7 Compare November 18, 2021 10:10
@mavasani mavasani marked this pull request as ready for review November 18, 2021 10:12
@mavasani
Copy link
Copy Markdown
Contributor Author

@CyrusNajmabadi this should be ready for review

Copy link
Copy Markdown
Contributor

@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.

overall i'm highly supportive of this. however, i think we shoudl takea slightly longer view and try to get this benefit without forcing the 'low' group only for suppressions. we have the 'low' concept today for many fixes and refactorings. Indeed, internally we have 'low' and 'lowest' (the latter is used for config/suppress). So i think we shoudl model the entire stack from top to bottom this way.

It will prevent a lot of confusing mismatches about which sort of 'low' we're talking about.

@mavasani
Copy link
Copy Markdown
Contributor Author

@CyrusNajmabadi Thanks for the feedback, I have addressed your comments, please take a look.

@mavasani mavasani force-pushed the AsyncLightBulb_LowPri branch from 590238c to c75be31 Compare November 24, 2021 03:41
@mavasani mavasani force-pushed the AsyncLightBulb_LowPri branch from c75be31 to da34e59 Compare November 24, 2021 03:44
Copy link
Copy Markdown
Contributor

@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.

nice. this got a lot cleaner. i like it. just some basic suggestions for clarity. tehre are some places that could use some comments to help with understanding.

@mavasani
Copy link
Copy Markdown
Contributor Author

mavasani commented Dec 1, 2021

Thank you for the review @CyrusNajmabadi!

@mavasani mavasani enabled auto-merge December 1, 2021 05:13
@mavasani mavasani merged commit 24a1d4b into dotnet:main Dec 1, 2021
@ghost ghost modified the milestones: 17.1, Next Dec 1, 2021
@mavasani mavasani deleted the AsyncLightBulb_LowPri branch December 1, 2021 17:07
mavasani added a commit to mavasani/roslyn that referenced this pull request Dec 17, 2021
…edit/1450689)

This regression was introduced with async lightbulb performance improvement PR: dotnet#56959. With that PR, we now optimize/reduce the number of analyzers to execute in the "Normal" priority bucket for async light bulb. We earlier executed all analyzers in this bucket, but now only try to execute analyzers which report at least one diagnostic ID which has a corresponding code fix provider that can fix that diagnostic ID.

To identify this reduced set of analyzers, we execute this newly added perf optimization to skip analyzers that don't have a code fix: https://github.com/dotnet/roslyn/blob/88f829939583d49d9e08104a71a7645d712bcfbc/src/Features/Core/Portable/Diagnostics/EngineV2/DiagnosticIncrementalAnalyzer_GetDiagnosticsForSpan.cs#L151-L155

`_owner.DiagnosticAnalyzerInfoCache.GetDiagnosticDescriptors` call in this code is problematic for TS analyzers, because these are not regular DiagnosticAnalyzer sub-types, but instead derive from our internal DocumentDiagnosticAnalyzer and ProjectDiagnosticAnalyzer types, and this analyzer lies to us and returns 0 supported diagnostic descriptors: https://github.com/dotnet/roslyn/blob/315c2e149ba7889b0937d872274c33fcbfe9af5f/src/Features/Core/Portable/ExternalAccess/VSTypeScript/VSTypeScriptDocumentDiagnosticAnalyzer.cs#L16 and https://github.com/dotnet/roslyn/blob/315c2e149ba7889b0937d872274c33fcbfe9af5f/src/Features/Core/Portable/ExternalAccess/VSTypeScript/VSTypeScriptProjectDiagnosticAnalyzer.cs#L16. So, we skip TS analyzers for "Normal" priority bucket.

This PR implements a short term fix to update the newly added code to special case DocumentDiagnosticAnalyzers and skip the newly added perf optimization for these analyzers. Note that ProjectDiagnosticAnalyzers are never executed in lightbulb/code fix path.

I will create a separate issue to track designing a better long term solution for TS analyzers to avoid such breaking changes in future.
mavasani added a commit to mavasani/roslyn that referenced this pull request Dec 17, 2021
…edit/1450689)

This regression was introduced with async lightbulb performance improvement PR: dotnet#56959. With that PR, we now optimize/reduce the number of analyzers to execute in the "Normal" priority bucket for async light bulb. We earlier executed all analyzers in this bucket, but now only try to execute analyzers which report at least one diagnostic ID which has a corresponding code fix provider that can fix that diagnostic ID.

To identify this reduced set of analyzers, we execute this newly added perf optimization to skip analyzers that don't have a code fix: https://github.com/dotnet/roslyn/blob/88f829939583d49d9e08104a71a7645d712bcfbc/src/Features/Core/Portable/Diagnostics/EngineV2/DiagnosticIncrementalAnalyzer_GetDiagnosticsForSpan.cs#L151-L155

`_owner.DiagnosticAnalyzerInfoCache.GetDiagnosticDescriptors` call in this code is problematic for TS analyzers, because these are not regular DiagnosticAnalyzer sub-types, but instead derive from our internal DocumentDiagnosticAnalyzer and ProjectDiagnosticAnalyzer types, and this analyzer lies to us and returns 0 supported diagnostic descriptors: https://github.com/dotnet/roslyn/blob/315c2e149ba7889b0937d872274c33fcbfe9af5f/src/Features/Core/Portable/ExternalAccess/VSTypeScript/VSTypeScriptDocumentDiagnosticAnalyzer.cs#L16 and https://github.com/dotnet/roslyn/blob/315c2e149ba7889b0937d872274c33fcbfe9af5f/src/Features/Core/Portable/ExternalAccess/VSTypeScript/VSTypeScriptProjectDiagnosticAnalyzer.cs#L16. So, we skip TS analyzers for "Normal" priority bucket.

This PR implements a short term fix to update the newly added code to special case DocumentDiagnosticAnalyzers and skip the newly added perf optimization for these analyzers. Note that ProjectDiagnosticAnalyzers are never executed in lightbulb/code fix path.

I will create a separate issue to track designing a better long term solution for TS analyzers to avoid such breaking changes in future.
@Cosifne Cosifne modified the milestones: Next, 17.1.P3 Jan 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants