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

Run providers in parallel when determining if we should show the lightbulb icon #73758

Merged
merged 2 commits into from
May 29, 2024

Conversation

CyrusNajmabadi
Copy link
Member

Right now when determining if the lightbulb shoudl appear, we run providers serially, ending up with a long serial chain of costs like so:

image

individually providers aren't that expensive. But when we have dozens to hundreds of them, this adds up.

This PR switches to running them in parallel, canceling either whne we are told to stop, or the moment we find one that has a refactoring.

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner May 29, 2024 00:09
@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 29, 2024
// We want to pass linkedTokenSource.Token here so that we can cancel the inner operation once the
// outer ProducerConsumer sees a single refactoring returned by any provider.
var refactoring = await @this.GetRefactoringFromProviderAsync(
document, state, provider, options, linkedTokenSource.Token).ConfigureAwait(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

linkedTokenSource.Token

Is it possible to get a ObjectDisposedException here if this has been disposed?

Copy link
Member Author

@CyrusNajmabadi CyrusNajmabadi May 29, 2024

Choose a reason for hiding this comment

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

It should not be possible. we only dispose after the call to RunParallelAsync has completed. And it only completes Asher both the producer and consumer complete.

Copy link
Contributor

Choose a reason for hiding this comment

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

took a minute to process, but yeah, that makes sense. Thanks!

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:

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