-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Cache diagnostic analyzer computation #80045
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
Conversation
|
||
return builder.ToImmutableAndClear(); | ||
|
||
async Task<bool> IsCandidateForDeprioritizationBasedOnRegisteredActionsAsync(DiagnosticAnalyzer analyzer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this method is unchanged.
HostAnalyzerInfo? hostAnalyzerInfo = null; | ||
CompilationWithAnalyzersPair? compilationWithAnalyzers = null; | ||
|
||
foreach (var analyzer in analyzers) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this loop is virtually the same. just we avoid any work if we've already computed and cached the value for an analyzer in the past.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's merge once this gets far enough in CI that we have confidence it's not messing things up on the GitHub side
|
||
internal sealed partial class DiagnosticAnalyzerService | ||
{ | ||
private static readonly ConditionalWeakTable<DiagnosticAnalyzer, StrongBox<bool>> s_analyzerToIsDeprioritizationCandidateMap = new(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. I will doc. This is all part of a heuristics system that attempts to tell if an analyzer should be deprioritized when computing lightbulb actions. really all it does is ask "does this analyzer register any SymbolStart/SemanticModel actions". If so, then it should be deprioritized. So the only thing that matters here is if the same DiagAnalyzer instance might produce a different result when computed against a different compilation.
Teh answer is "yes it might". examples could include if this registered different actions in a VBComp vs a C# one (for DiagAnalyzers taht work on both langs), or if it sometimes registered those actions and sometimes did not, based on some aspect of the compilation it ran against.
However, the likelihood of this happening is super small. And in that case, all that that means is that we run the analyzer at a different priority class than we would otehrwise run it.
Again, in all cases, we run all analyzers. This jus taffects how we order them. And so being slightly wrong (because we cahced some earlier data that is EXTREMELY unlikely to ever change within a run of VS) is fine.
46 PRs before and 36 after ```diff + * [Cache diagnostic analyzer computation](dotnet/roslyn#80045) + * [Remove parameter always passed the same value](dotnet/roslyn#80042) * [Update doc for IMethodSymbol.IsExtensionMethod](dotnet/roslyn#80016) * [Don't cache known-broken compositions](dotnet/roslyn#80021) * [Cleanup methods in DiagAnalyzerService](dotnet/roslyn#80013) * [Simplify processing of errors reported by the build](dotnet/roslyn#79964) * [Additional cleanup of the DiagnosticAnalyzerServier](dotnet/roslyn#80005) * [Fix Code Lens around source generated files](dotnet/roslyn#79992) * [Remove superflous DiagService api that can be achieved with existing apis](dotnet/roslyn#80007) * [Generate `init` accessor for required properties inside `readonly struct`s](dotnet/roslyn#80004) * [Remove existing low level diag oop code now that it's all handled at higher levels.](dotnet/roslyn#79994) * [Allow large InlineHint ArrayBuilder pooling](dotnet/roslyn#79857) * [Reduce allocations obtaining classified spans in ClassifierHelper](dotnet/roslyn#79856) * [Compute span diagnostics in oop](dotnet/roslyn#79991) * [Allow Razor cohosting to work with non-Razor SDK projects](dotnet/roslyn#79953) * [Move computation of deprioritized analyzers to oop](dotnet/roslyn#79989) * [EnC: Fix symbol mapping of delegates with indexed name](dotnet/roslyn#79837) * [Emit telemetry 'durations' with known radix point '.'](dotnet/roslyn#79988) * [Move logic up into DiagService](dotnet/roslyn#79985) * [Move the StateManager type up to the DiagnosticService from the DiagnosticIncrementalANalyzer](dotnet/roslyn#79984) * [Immediately remote diagnostics call to OOP](dotnet/roslyn#79983) * [Build Microsoft.CodeAnalysis.SemanticSearch.Extension ref assembly for use in semantic search queries](dotnet/roslyn#79972) * [Only cache compilation if we have the same set of analyzers](dotnet/roslyn#79978) * [Delete unused property](dotnet/roslyn#79963) * [Update 'use expr body' to be a purely syntactic analyzer](dotnet/roslyn#79979) * [Mark 'Use expr body' as a syntax-only fixer](dotnet/roslyn#79971) * [♻️ MSBuildWorkspaceDirectory - Fallback to AppContext.BaseDirectory when Assembly Location is empty](dotnet/roslyn#79934) * [Merge runtime async support into main](dotnet/roslyn#79833) * [Implement "Simplify property accessor" feature](dotnet/roslyn#79754) - * Merge main to runtime async branch (PR: [#79961](dotnet/roslyn#79961)) * [Redo how and when we report source generator telemetry](dotnet/roslyn#79951) * [Allow MEF components to supply assembly path resolvers](dotnet/roslyn#79218) * [Allow Razor to hook up the source generator in misc files](dotnet/roslyn#79891) * [Block ENC for extension blocks](dotnet/roslyn#79883) * [Upgrade servicehub.client to fix test source discovery](dotnet/roslyn#79899) * [Update package restore error message.](dotnet/roslyn#79876) - * Merge main (PR: [#79834](dotnet/roslyn#79834)) - * Merge main (PR: [#79830](dotnet/roslyn#79830)) * [Baseline struct lifting tests](dotnet/roslyn#79505) - * Merge main to runtime async branch (PR: [#79582](dotnet/roslyn#79582)) - * Merge main (PR: [#79424](dotnet/roslyn#79424)) - * Merge main (PR: [#78994](dotnet/roslyn#78994)) - * Merge main to runtime async branch (PR: [#78740](dotnet/roslyn#78740)) - * Merge main to runtime async branch (PR: [#78517](dotnet/roslyn#78517)) - * Merge main to runtime async branch (PR: [#78114](dotnet/roslyn#78114)) - * Merge main to runtime async branch (PR: [#77700](dotnet/roslyn#77700)) - * Merge main to runtime async branch (PR: [#77533](dotnet/roslyn#77533)) - * Merge main to runtime async branch (PR: [#77265](dotnet/roslyn#77265)) ```
This may address RPS regressions in https://dev.azure.com/devdiv/DevDiv/_git/VS/pullrequest/664820
Addressing lots of allocations seen in traces:
Build: https://devdiv.visualstudio.com/DefaultCollection/DevDiv/_build/results?buildId=12269166&view=results
PR: https://dev.azure.com/devdiv/DevDiv/_git/VS/pullrequest/665101
Build2: https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=12276921&view=results