diff --git a/src/Workspaces/Remote/Core/Diagnostics/DiagnosticComputer.cs b/src/Workspaces/Remote/Core/Diagnostics/DiagnosticComputer.cs index c95e61c8d4fef1352cabd862e8c37039454b27e4..5fb4c61aa0af119a176ae5c316ed3e3fe74cc395 100644 --- a/src/Workspaces/Remote/Core/Diagnostics/DiagnosticComputer.cs +++ b/src/Workspaces/Remote/Core/Diagnostics/DiagnosticComputer.cs @@ -54,15 +54,24 @@ public DiagnosticComputer(Project project) bool logAnalyzerExecutionTime, CancellationToken cancellationToken) { + // flag that controls concurrency + var useConcurrent = true; + + // get original compilation var compilation = await _project.GetCompilationAsync(cancellationToken).ConfigureAwait(false); + // fork compilation with concurrent build. this is okay since WithAnalyzers will fork compilation + // anyway to attach event queue. this should make compiling compilation concurrent and make things + // faster + compilation = compilation.WithOptions(compilation.Options.WithConcurrentBuild(useConcurrent)); + // TODO: can we support analyzerExceptionFilter in remote host? // right now, host doesn't support watson, we might try to use new NonFatal watson API? var analyzerOptions = new CompilationWithAnalyzersOptions( options: new WorkspaceAnalyzerOptions(_project.AnalyzerOptions, _project.Solution.Workspace), onAnalyzerException: OnAnalyzerException, analyzerExceptionFilter: null, - concurrentAnalysis: true, + concurrentAnalysis: useConcurrent, logAnalyzerExecutionTime: logAnalyzerExecutionTime, reportSuppressedDiagnostics: reportSuppressedDiagnostics); diff --git a/src/Workspaces/Remote/ServiceHub/Shared/ServiceHubServiceBase.cs b/src/Workspaces/Remote/ServiceHub/Shared/ServiceHubServiceBase.cs index 6fbbcb4b060e75079ad9c124d84c83ecb95f8b4a..44f7c95c5f080a6b70f71c2868bbbddc2287fc37 100644 --- a/src/Workspaces/Remote/ServiceHub/Shared/ServiceHubServiceBase.cs +++ b/src/Workspaces/Remote/ServiceHub/Shared/ServiceHubServiceBase.cs @@ -105,7 +105,7 @@ protected virtual void Dispose(bool disposing) protected void LogError(string message) { - Logger.TraceEvent(TraceEventType.Error, 0, $"{DebugInstanceString} : " + message); + Log(TraceEventType.Error, message); } public virtual void Initialize(int sessionId, byte[] solutionChecksum) @@ -132,6 +132,11 @@ protected virtual void OnDisconnected(JsonRpcDisconnectedEventArgs e) // do nothing } + protected void Log(TraceEventType errorType, string message) + { + Logger.TraceEvent(errorType, 0, $"{DebugInstanceString} : " + message); + } + private void OnRpcDisconnected(object sender, JsonRpcDisconnectedEventArgs e) { // raise cancellation @@ -141,7 +146,10 @@ private void OnRpcDisconnected(object sender, JsonRpcDisconnectedEventArgs e) if (e.Reason != DisconnectedReason.Disposed) { - LogError($"Client stream disconnected unexpectedly: {e.Exception?.GetType().Name} {e.Exception?.Message}"); + // this is common for us since we close connection forcefully when operation + // is cancelled. use Warning level so that by default, it doesn't write out to + // servicehub\log files. one can still make this to write logs by opting in. + Log(TraceEventType.Warning, $"Client stream disconnected unexpectedly: {e.Exception?.GetType().Name} {e.Exception?.Message}"); } } }