Skip to content

Commit

Permalink
Merge pull request #11025 from heejaechang/directdependency
Browse files Browse the repository at this point in the history
change default to only re-analyze direct dependencies rather than all…
  • Loading branch information
heejaechang committed May 3, 2016
2 parents 20e63dc + ef7e97b commit 794f8c7
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 13 deletions.
31 changes: 24 additions & 7 deletions src/EditorFeatures/Test/SolutionCrawler/WorkCoordinatorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -696,12 +696,14 @@ End Property
}

[Fact, WorkItem(739943, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/739943")]
public async Task SemanticChange_Propagation()
public async Task SemanticChange_Propagation_Transitive()
{
var solution = GetInitialSolutionInfoWithP2P();

using (var workspace = new WorkCoordinatorWorkspace(SolutionCrawler))
{
workspace.Options = workspace.Options.WithChangedOption(InternalSolutionCrawlerOptions.DirectDependencyPropagationOnly, false);

workspace.OnSolutionAdded(solution);
await WaitWaiterAsync(workspace.ExportProvider);

Expand All @@ -712,13 +714,28 @@ public async Task SemanticChange_Propagation()

Assert.Equal(1, worker.SyntaxDocumentIds.Count);
Assert.Equal(4, worker.DocumentIds.Count);
}
}

#if false
Assert.True(1 == worker.SyntaxDocumentIds.Count,
string.Format("Expected 1 SyntaxDocumentIds, Got {0}\n\n{1}", worker.SyntaxDocumentIds.Count, GetListenerTrace(workspace.ExportProvider)));
Assert.True(4 == worker.DocumentIds.Count,
string.Format("Expected 4 DocumentIds, Got {0}\n\n{1}", worker.DocumentIds.Count, GetListenerTrace(workspace.ExportProvider)));
#endif
[Fact, WorkItem(739943, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/739943")]
public async Task SemanticChange_Propagation_Direct()
{
var solution = GetInitialSolutionInfoWithP2P();

using (var workspace = new WorkCoordinatorWorkspace(SolutionCrawler))
{
workspace.Options = workspace.Options.WithChangedOption(InternalSolutionCrawlerOptions.DirectDependencyPropagationOnly, true);

workspace.OnSolutionAdded(solution);
await WaitWaiterAsync(workspace.ExportProvider);

var id = solution.Projects[0].Id;
var info = DocumentInfo.Create(DocumentId.CreateNewId(id), "D6");

var worker = await ExecuteOperation(workspace, w => w.OnDocumentAdded(info));

Assert.Equal(1, worker.SyntaxDocumentIds.Count);
Assert.Equal(3, worker.DocumentIds.Count);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ internal static class InternalSolutionCrawlerOptions
public const string OptionName = "SolutionCrawler";

public static readonly Option<bool> SolutionCrawler = new Option<bool>("FeatureManager/Components", "Solution Crawler", defaultValue: true);
public static readonly Option<bool> DirectDependencyPropagationOnly = new Option<bool>(OptionName, "Project propagation only on direct dependency", defaultValue: true);

public static readonly Option<int> ActiveFileWorkerBackOffTimeSpanInMS = new Option<int>(OptionName, "Active file worker backoff timespan in ms", defaultValue: 400);
public static readonly Option<int> AllFilesWorkerBackOffTimeSpanInMS = new Option<int>(OptionName, "All files worker backoff timespan in ms", defaultValue: 1500);
public static readonly Option<int> EntireProjectWorkerBackOffTimeSpanInMS = new Option<int>(OptionName, "Entire project analysis worker backoff timespan in ms", defaultValue: 5000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,7 @@ private void EnqueueFullProjectDependency(Document document, IAssemblySymbol int
// most likely we got here since we are called due to typing.
// calculate dependency here and register each affected project to the next pipe line
var solution = document.Project.Solution;

var graph = solution.GetProjectDependencyGraph();
foreach (var projectId in graph.GetProjectsThatTransitivelyDependOnThisProject(self).Concat(self))
foreach (var projectId in GetProjectsToAnalyze(solution, self))
{
var project = solution.GetProject(projectId);
if (project == null)
Expand Down Expand Up @@ -289,6 +287,20 @@ public void Enqueue(Document document, SyntaxPath changedMember)
}
}

private static IEnumerable<ProjectId> GetProjectsToAnalyze(Solution solution, ProjectId projectId)
{
var graph = solution.GetProjectDependencyGraph();

if (solution.Workspace.Options.GetOption(InternalSolutionCrawlerOptions.DirectDependencyPropagationOnly))
{
return graph.GetProjectsThatDirectlyDependOnThisProject(projectId).Concat(projectId);
}

// re-analyzing all transitive dependencies is very expensive. by default we will only
// re-analyze direct dependency for now. and consider flipping the default only if we must.
return graph.GetProjectsThatTransitivelyDependOnThisProject(projectId).Concat(projectId);
}

private struct Data
{
public readonly Document Document;
Expand Down Expand Up @@ -392,9 +404,7 @@ protected override async Task ExecuteAsync()

// do dependency tracking here with current solution
var solution = _registration.CurrentSolution;

var graph = solution.GetProjectDependencyGraph();
foreach (var projectId in graph.GetProjectsThatTransitivelyDependOnThisProject(data.ProjectId).Concat(data.ProjectId))
foreach (var projectId in GetProjectsToAnalyze(solution, data.ProjectId))
{
project = solution.GetProject(projectId);
await EnqueueWorkItemAsync(project).ConfigureAwait(false);
Expand Down

0 comments on commit 794f8c7

Please sign in to comment.