Spikes in CPU usage when resolving references to methods implementing System.IDisposable #38223
Labels
Area-IDE
Concept-Continuous Improvement
IDE-Navigation
Navigation and search
Need More Info
The issue needs more information to proceed.
Milestone
Finding references to a method that implement System.IDisposable in any non-trivially sized project takes a long time and causes a big spike in CPU usage. I replicated this behaviour in VS2019, VS2017 and VSCode with omnisharp. It's impossible to avoid this issue if you want to use Code Lens.
After making a cpu profile, it seems that core issue is here:
roslyn/src/Workspaces/Core/Portable/FindSymbols/FindReferences/DependentProjectsFinder.cs
Lines 442 to 464 in d570d6c
Namely, to find references to MyClass.Dispose(), Roslyn first tries to find all classes that implement System.IDisposable, with first step being filtering all projects in solution to those which have access to assembly containing System.IDisposable. Checking whether a project has access to the said assembly involves creating a whole new compilation object, and this is what seems to be taking most of the cpu cycles.
I assume what @CyrusNajmabadi remarked in the TODO would resolve/help with this issue?
The text was updated successfully, but these errors were encountered: