Description
Hey folks, I'm from the Visual Studio performance team and our telemetry is showing that Codist is causing responsiveness issues in the wild by consuming large amounts of thread pool threads.
Over the past 21 days at times where Visual Studio's thread pool has been starved, we've captured the following data:
Failure | Score | Cab Count | Threads 90th | Threads 50th | Avg Threads |
---|---|---|---|---|---|
Codist!Unknown | 16 | 4 | 28 | 5 | 12 |
In particular these lines are the problem:
Codist/Codist/Taggers/CSharpTagger.cs
Lines 240 to 244 in f38f7e4
It appears that this code is attemping to monitor the specified CancellationToken, and when triggered, cancel the parsing. When it does this, however, it consumes a thread - and in the wild, we saw that this path consumed up to 28 threads at its worst.
Instead there's an easier way to monitor cancellation and avoid the thread starvation; use CancellationToken.Register. Do however, make note, that by default the call back will run in context of the code that triggers the cancellation. If that is unwanted, and you want to maintain the existing behavior, call Register(() => {...}, useSynchronizationContext: true)
.
Thanks
Dave
Activity