Fix PerfWatson hang 1357805#7858
Conversation
A hang was detected by the PerfWatson tool in VsSolutionEventListener.PrioritizedOnAfterOpenProject() when trying to get the ActiveWorkspaceProjectContext. After an analysis with Windbg using the command !dumpasync we can see that many tasks are blocked waiting for _instanceTaskSource Since this is not 100% reproducible, and we only have a coredump, we are just removing possible hangs in Task.GetAwaiter().GetResult().
| (_, initializeAsyncTask) = _instanceTaskSource.Task.GetAwaiter().GetResult(); | ||
| } | ||
| // Should throw TaskCanceledException if already cancelled in Dispose | ||
| (T instance, JoinableTask initializeAsyncTask)? oldInstanceTask = await _instanceTaskSource.Task; |
There was a problem hiding this comment.
If the task is completed, isn't it safe to call GetAwaiter().GetResult()?
There was a problem hiding this comment.
Can GetAwaiter().GetResult() pattern block the main thread ? In the debugger this line is blocked.
Can you provide more details on this bit please? This change appears to be replacing the |
|
Coredump: List of tasks that are blocked: 148f99a2960 <0> Microsoft.VisualStudio.Threading.ThreadingTools+d__9 @ 7ff8ba46f5b0 148f99a43e0 <0> Microsoft.VisualStudio.Threading.ThreadingTools+d__9 @ 7ff8ba46f5b0 148f99a57d8 <-1> Microsoft.VisualStudio.ProjectSystem.LanguageServices.WorkspaceProjectContextProvider+d__5 @ 7ff86a51cbd0 1497989e3a0 <0> Microsoft.VisualStudio.Threading.ThreadingTools+d__9 @ 7ff8ba46f5b0 1497989fe70 <0> Microsoft.VisualStudio.Threading.ThreadingTools+d__9 @ 7ff8ba46f5b0 148f99a2448 <1> * Microsoft.VisualStudio.Threading.AsyncLazy+<>c__DisplayClass13_0+<b__0>d<System.Object> @ 7ff8ba4716c0 148f99a3f50 <1> * Microsoft.VisualStudio.Threading.AsyncLazy+<>c__DisplayClass13_0+<b__0>d<System.Object> @ 7ff8ba4716c0 148f99a1f20 <1> * Microsoft.VisualStudio.Threading.AsyncLazy+<>c__DisplayClass13_0+<b__0>d<System.Object> @ 7ff8ba4716c0 1497989dda0 <1> * Microsoft.VisualStudio.Threading.AsyncLazy+<>c__DisplayClass13_0+<b__0>d<System.Object> @ 7ff8ba4716c0 1497989f9f8 <1> * Microsoft.VisualStudio.Threading.AsyncLazy+<>c__DisplayClass13_0+<b__0>d<System.Object> @ 7ff8ba4716c0 149798ef518 <0> Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.TreePublishingBatchService+d__14 @ 7ff86f6ed660 14978da0520.SwitchToMainThreadAsync 148f8b97d08.SwitchToMainThreadAsync 148f8b8c430.SwitchToMainThreadAsync 148f8b4f0b0.SwitchToMainThreadAsync 148f8b3e848.SwitchToMainThreadAsync 148f98fde68 <0> Microsoft.VisualStudio.Threading.ThreadingTools+d__9 @ 7ff8ba46f5b0 149794f1c58 <0> Microsoft.VisualStudio.Threading.ThreadingTools+d__9 @ 7ff8ba46f5b0 149794f3390 <0> Microsoft.VisualStudio.Threading.ThreadingTools+d__9 @ 7ff8ba46f5b0 14979790410 <0> Microsoft.VisualStudio.Threading.ThreadingTools+d__9 @ 7ff8ba46f5b0 148f9a0d988 <0> Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.ProjectConfigHostBridge+d__53 @ 7ff86f69a980 14977bf9ac8 <0> Microsoft.VisualStudio.RemoteSettings.TargetedNotificationsProviderBase+d__29 @ 7ff8b244c0a0 |
davkean
left a comment
There was a problem hiding this comment.
This does not fix the hang, this is caused by the active workspace context host waiting on the wrong configuration and nothing to do with guarding the wait. Please sync with me offline before attempting to fix this.
|
This w as a bug in MEF and here is the fix microsoft/vs-mef#294 |
Fix AB#1357805
A hang was detected by the PerfWatson tool in VsSolutionEventListener.PrioritizedOnAfterOpenProject() when trying to get the ActiveWorkspaceProjectContext.
After an analysis with Windbg using the command !dumpasync we can see that many tasks are blocked waiting for _instanceTaskSource
Since this is not 100% reproducible, and we only have a coredump, we are just removing possible hangs in Task.GetAwaiter().GetResult().
Microsoft Reviewers: Open in CodeFlow