Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove less individual sync calls to get compilation options. #72951

Merged
merged 6 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,9 @@ public async Task FindAsync(

if (searchingChecksumsLeft.Remove(projectStateChecksums.Info))
result[projectStateChecksums.Info] = projectState.Attributes;

if (searchingChecksumsLeft.Remove(projectStateChecksums.CompilationOptions))
result[projectStateChecksums.CompilationOptions] = projectState.CompilationOptions!;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,14 +243,24 @@ private async Task<Solution> UpdateProjectsAsync(
Dictionary<ProjectId, ProjectStateChecksums> newProjectIdToStateChecksums,
CancellationToken cancellationToken)
{
// Note: it's common to see a whole lot of project-infos change. So attempt to collect that in one go
// if we can.
using var _ = PooledHashSet<Checksum>.GetInstance(out var projectInfoChecksums);
foreach (var (projectId, newProjectChecksums) in newProjectIdToStateChecksums)
projectInfoChecksums.Add(newProjectChecksums.Info);
// Note: it's common to need to collect a large set of project-attributes and compilation options. So
// attempt to collect all of those in a single call for each kind instead of a call for each instance
// needed.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code only really needs to execute on changed projects, rignt? If so, could we move this code down there and have it only work on checksums from those projects?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed and added projects. which is precisely what is in newProjectIdToStateChecksums.

{
using var _ = PooledHashSet<Checksum>.GetInstance(out var projectItemChecksums);
foreach (var (_, newProjectChecksums) in newProjectIdToStateChecksums)
projectItemChecksums.Add(newProjectChecksums.Info);

await _assetProvider.GetAssetsAsync<ProjectInfo.ProjectAttributes, VoidResult>(
assetPath: AssetPath.SolutionAndTopLevelProjectsOnly, projectItemChecksums, callback: null, arg: default, cancellationToken).ConfigureAwait(false);

await _assetProvider.GetAssetsAsync<ProjectInfo.ProjectAttributes, VoidResult>(
assetPath: AssetPath.SolutionAndTopLevelProjectsOnly, projectInfoChecksums, callback: null, arg: default, cancellationToken).ConfigureAwait(false);
projectItemChecksums.Clear();
foreach (var (_, newProjectChecksums) in newProjectIdToStateChecksums)
projectItemChecksums.Add(newProjectChecksums.CompilationOptions);

await _assetProvider.GetAssetsAsync<CompilationOptions, VoidResult>(
assetPath: AssetPath.SolutionAndTopLevelProjectsOnly, projectItemChecksums, callback: null, arg: default, cancellationToken).ConfigureAwait(false);
}

// added project
foreach (var (projectId, newProjectChecksums) in newProjectIdToStateChecksums)
Expand Down
Loading