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

Update code cleanup to run in parallel #73368

Merged
merged 3 commits into from
May 7, 2024

Conversation

CyrusNajmabadi
Copy link
Member

Saves >15 minutes running this on roslyn.

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner May 7, 2024 17:29
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels May 7, 2024
solution.Workspace,
(progress, cancellationToken) => FixProjectsAsync(
_globalOptions, solution, solution.Projects.Where(p => p.SupportsCompilation).ToImmutableArray(), context.EnabledFixIds, progress, cancellationToken),
context);
Copy link
Member Author

Choose a reason for hiding this comment

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

just inlined the local function version. Note: FixSolution became FixProjects where the set of projects to fix is passed in.

// Just defer to FixProjectsAsync, passing in all fixable projects in the solution.
(progress, cancellationToken) => FixProjectsAsync(
_globalOptions, solution, solution.Projects.Where(p => p.SupportsCompilation).ToImmutableArray(), context.EnabledFixIds, progress, cancellationToken),
context).ConfigureAwait(false);
Copy link
Member Author

Choose a reason for hiding this comment

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

inlined this method.

// Just defer to FixProjectsAsync, passing in this single project to fix.
(progress, cancellationToken) => FixProjectsAsync(
_globalOptions, project.Solution, [project], context.EnabledFixIds, progress, cancellationToken),
context).ConfigureAwait(false);
Copy link
Member Author

Choose a reason for hiding this comment

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

inlined this method.

var newDocument = await FixDocumentAsync(document, context.EnabledFixIds, progress, options, cancellationToken).ConfigureAwait(true);
return newDocument.Project.Solution;
},
context).ConfigureAwait(false);
Copy link
Member Author

Choose a reason for hiding this comment

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

inlined this methodl

// FixDocumentAsync reports progress within a document, but we only want to report progress at
// the document granularity. So we pass CodeAnalysisProgress.None here so that inner progress
// updates don't affect us.
var fixedDocument = await FixDocumentAsync(document, args.enabledFixIds, CodeAnalysisProgress.None, ideOptions, cancellationToken).ConfigureAwait(false);
Copy link
Member Author

Choose a reason for hiding this comment

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

note that this logic is different from before. now we operate in parallel, always processing documents from the original solution (previously we would process a document, fork the solution, and repeat). This was obviously insanely slow.

await foreach (var (documentId, newRoot) in stream)
currentSolution = currentSolution.WithDocumentSyntaxRoot(documentId, newRoot);

return currentSolution;
Copy link
Member Author

Choose a reason for hiding this comment

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

now we can apply all the changes in one go to the solution, producing the final solution in one shot.

@CyrusNajmabadi CyrusNajmabadi requested a review from ToddGrun May 7, 2024 18:03
@CyrusNajmabadi
Copy link
Member Author

@ToddGrun ptal.

Copy link
Contributor

@ToddGrun ToddGrun left a comment

Choose a reason for hiding this comment

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

:shipit:

@CyrusNajmabadi CyrusNajmabadi enabled auto-merge May 7, 2024 18:59
@CyrusNajmabadi CyrusNajmabadi merged commit fca6e1f into dotnet:main May 7, 2024
25 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone May 7, 2024
@CyrusNajmabadi CyrusNajmabadi deleted the parallelCodeCleanup branch May 7, 2024 20:14
@CyrusNajmabadi
Copy link
Member Author

@jasonmalinowski For review when you get back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants