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

Move more code over to producer/consumer model #73331

Merged
merged 17 commits into from
May 3, 2024

Conversation

CyrusNajmabadi
Copy link
Member

No description provided.

@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 3, 2024
/// Version of RunAsync that will process <paramref name="source"/> in parallel.
/// </summary>
public static Task RunParallelAsync<TSource, TArgs>(
IAsyncEnumerable<TSource> source,
Copy link
Member Author

Choose a reason for hiding this comment

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

this overload operates on an IAsyncEnumerable source. I can't find ways to make these overloads without a lot of duplication of the bodies unfortunately.

{
return Documents.Concat(await GetSourceGeneratedDocumentsAsync(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.

old approach blocked the caller until SG docs were generated. New approach allows the actual docs to be returned first.

@CyrusNajmabadi CyrusNajmabadi marked this pull request as ready for review May 3, 2024 18:50
@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner May 3, 2024 18:50
@CyrusNajmabadi
Copy link
Member Author

@ToddGrun Second to last one of these. I only have one more change i want to make in this area.

@CyrusNajmabadi CyrusNajmabadi requested a review from ToddGrun May 3, 2024 20:15
@@ -130,7 +130,10 @@ public static Generator CreateAndWriteCapabilitiesVertex(ILsifJsonWriter lsifJso
}
};

var documents = (await project.GetAllRegularAndSourceGeneratedDocumentsAsync(cancellationToken)).ToList();
var documents = new List<Document>();
Copy link
Contributor

Choose a reason for hiding this comment

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

var documents = new List();

Was something wrong here? Was the loop below intended to be changed to use the new parallel methods?

Copy link
Member Author

Choose a reason for hiding this comment

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

no. i just needed to update this code because GetAllRegularAndSourceGeneratedDocumentsAsync now returns an IAsyncEnumerable.

}
using var _ = ArrayBuilder<Diagnostic>.GetInstance(out var diagnostics);
await ProducerConsumer<Diagnostic>.RunParallelAsync(
source: project.GetAllRegularAndSourceGeneratedDocumentsAsync(cancellationToken),
Copy link
Contributor

Choose a reason for hiding this comment

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

GetAllRegularAndSourceGeneratedDocumentsAsync

Why doesn't the code use project.Documents as part of it's source input either here or in the else?

Copy link
Contributor

Choose a reason for hiding this comment

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

yep, this is better.

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 3, 2024 23:43
@CyrusNajmabadi CyrusNajmabadi merged commit a06a6ee into dotnet:main May 3, 2024
25 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone May 4, 2024
@CyrusNajmabadi CyrusNajmabadi deleted the taskWhenAll2 branch May 4, 2024 00:07
@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