Skip to content

Commit

Permalink
Merge pull request #17374 from heejaechang/TweakOOP
Browse files Browse the repository at this point in the history
2 tweaks on OOP.
  • Loading branch information
heejaechang authored Feb 24, 2017
2 parents 27bfd54 + 872316f commit 60efbb6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
11 changes: 10 additions & 1 deletion src/Workspaces/Remote/Core/Diagnostics/DiagnosticComputer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,24 @@ private async Task<DiagnosticAnalysisResultMap<string, DiagnosticAnalysisResultB
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);

Expand Down
12 changes: 10 additions & 2 deletions src/Workspaces/Remote/ServiceHub/Shared/ServiceHubServiceBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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}");
}
}
}
Expand Down

0 comments on commit 60efbb6

Please sign in to comment.