EWSoftware / VSSpellChecker

A Visual Studio spell checker editor extension that checks the spelling of comments, strings, and plain text as you type. Supports configuration and various languages.
Other
377 stars 65 forks source link

VSSpellChecker causing VS responsiveness issues by triggering GCs #244

Closed davkean closed 2 years ago

davkean commented 2 years ago

I'm from the Visual Studio performance team and our telemetry is showing us that VSSpellChecker extension is causing Visual Studio responsiveness issues by triggering GCs. In particular, the method SpellCheckFileInfo.sh has a high allocation pattern which over the past 21 days, has caused VS to freeze the following amounts:

Blame Expressed Hits Total Hits Duration (75th Percentile) Delayed Mouse Clicks Delayed Key Strokes
visualstudio.spellchecker.dll!VisualStudio.SpellChecker.ProjectSpellCheck.SpellCheckFileInfo.AllProjectFiles 408 497 1.90 sec 379 34

(This is heavily sampled, so real number of hits are close to 10x this amount)

Expressed delays are situations where the UI hung while within this method and it interrupted/prevented users mouse or keyboard input. Total hits are all the times the UI hung while within this method, regardless of whether input was interrupted.

To resolve this problem, SpellCheckFileInfo.AllProjectFiles should be changed to reduce the number of short term allocations. Examples include:

https://github.com/EWSoftware/VSSpellChecker/blob/bb3d6283434b2f297479f8430d6889d5b2d94978/Source/VSSpellCheckerShared/ProjectSpellCheck/SpellCheckFileInfo.cs#L232-L234 https://github.com/EWSoftware/VSSpellChecker/blob/bb3d6283434b2f297479f8430d6889d5b2d94978/Source/VSSpellCheckerShared/ProjectSpellCheck/SpellCheckFileInfo.cs#L256 https://github.com/EWSoftware/VSSpellChecker/blob/bb3d6283434b2f297479f8430d6889d5b2d94978/Source/VSSpellCheckerShared/ProjectSpellCheck/SpellCheckFileInfo.cs#L278 https://github.com/EWSoftware/VSSpellChecker/blob/bb3d6283434b2f297479f8430d6889d5b2d94978/Source/VSSpellCheckerShared/ProjectSpellCheck/SpellCheckFileInfo.cs#L280-L281

-Dave

EWSoftware commented 2 years ago

@davkean I've made changes to the affected code that should resolve the issue. The changes are in the latest releases that were just published (v2022.1.3.0 for VS 2017/2019 and VS 2022). If there are any subsequent issues, let me know and I'll try to fix them as well.