F# VS editor: reduce background CPU load by gating expensive analyzers to the active document only - #20117
Draft
xperiandri wants to merge 1 commit into
Draft
F# VS editor: reduce background CPU load by gating expensive analyzers to the active document only#20117xperiandri wants to merge 1 commit into
xperiandri wants to merge 1 commit into
Conversation
- Add ActiveDocumentDetection module (IVsMonitorSelection-based helper) - Gate UnusedDeclarationsAnalyzer to active document - Gate SimplifyNameDiagnosticAnalyzer to active document - Gate FSharpInlayHintsService to active document - Gate UnusedOpensDiagnosticAnalyzer to active document - Add ActiveDocumentDetection.fs to FSharp.Editor.fsproj Fixes dotnet#20114
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #20114
Summary
CPU profiling of
devenv.exe(VS Insiders + F# extension) showedThreadPoolWorkQueue.Dispatchat 72 % total / 59 % self, driven by continuous F# background analysis running for all open tabs, not just the active one.This PR implements the highest-impact P0 fixes from
docs/ide/background-activity-minimization-plan.md:Changes
New:
ActiveDocumentDetectionmodulevsintegration/src/FSharp.Editor/Diagnostics/ActiveDocumentDetection.fsShared helper that uses
IVsMonitorSelection/IVsWindowFrameto determine whether a RoslynDocumentis the currently focused VS editor tab.tryGetActiveDocumentMoniker— returnsstring voption(the active file path, orValueNone)isActiveDocument— returnsbool; falls back totrue(= don't suppress) when detection fails, so analysis is never silently lostGated analyzers / services
UnusedOpensDiagnosticAnalyzerActiveDocumentDetectionmoduleUnusedDeclarationsAnalyzerSimplifyNameDiagnosticAnalyzerFSharpInlayHintsServiceBehavior
BackgroundAnalysisScope.VisibleFilesAndOpenFilesWithPreviouslyReportedDiagnostics).Not in scope (tracked in the plan)
BackgroundAnalysisScopedefault change (item App.config in up-to-date check causes rebuilds #11) — needs a separate option keyCompilation.Emitversion-stamp cache (item Error while installing Visual F# Tools (05.01.2015) #5)hasDependentVersionChangedasync fix (item Method not fournd: SystemCollections.Generic IEqualityComparer'1 #6)ClassificationServicestale-result path (item Existing F# projects won't open if only VS2015 is installed #4)updateProjectOptionsdebounce (item Intellisense does not appear off of generic type #8)FSharpProjectOptionsReactorpriority queue (item Explicit field declaration generating property in F# classes #7)