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

Compute classifications for FAR results in parallel. #73599

Merged
merged 10 commits into from
May 21, 2024

Conversation

CyrusNajmabadi
Copy link
Member

@CyrusNajmabadi CyrusNajmabadi commented May 20, 2024

This is a large savings that gets us down to around 3 seconds for a expensive FAR total in Roslyn.

SoFast

@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 20, 2024
@CyrusNajmabadi CyrusNajmabadi marked this pull request as ready for review May 20, 2024 22:30
@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner May 20, 2024 22:30
@CyrusNajmabadi
Copy link
Member Author

@ToddGrun this is ready for review.

@@ -201,7 +201,7 @@ async ValueTask IFindUsagesContext.OnDefinitionFoundAsync(DefinitionItem definit
}
}

ValueTask IFindUsagesContext.OnReferenceFoundAsync(SourceReferenceItem reference, CancellationToken cancellationToken)
ValueTask IFindUsagesContext.OnReferencesFoundAsync(ImmutableArray<SourceReferenceItem> references, CancellationToken cancellationToken)
Copy link
Member Author

Choose a reason for hiding this comment

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

one change is that we're updating one of the APIs here to be chunky instead of chatty.

@@ -107,20 +108,26 @@ public async ValueTask OnDefinitionFoundAsync(SymbolGroup group, CancellationTok
}

public async ValueTask OnReferencesFoundAsync(
ImmutableArray<(SymbolGroup group, ISymbol symbol, ReferenceLocation location)> references, CancellationToken cancellationToken)
IAsyncEnumerable<(SymbolGroup group, ISymbol symbol, ReferenceLocation location)> references, CancellationToken cancellationToken)
Copy link
Member Author

Choose a reason for hiding this comment

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

another API is also moving to streaming, instead of chunking. Since it itself will have this ProducerCOnsumer.RunParallel in it. So it can just consume whatever is thrown at it, chunking it itself.

if (referenceItem != null)
await context.OnReferenceFoundAsync(referenceItem, cancellationToken).ConfigureAwait(false);
}
await ProducerConsumer<SourceReferenceItem>.RunParallelAsync(
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 logic is the major win. allowing us to be computing the info for hte fuond references in parallel, sending out chunks of them to the client as we can. while a chunk is in flight, we continually compute and buffer more. sending the next chunk once we can.

{
foreach (var (_, definition, location) in references)
lock (_gate)
Copy link
Contributor

Choose a reason for hiding this comment

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

lock (_gate)

nit: this takes the lock more now, right? No contention concerns?

Copy link
Member Author

Choose a reason for hiding this comment

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

it takes it as much as before. just the loop is here, instead of receiving the individual messages and taking the lock. i'm ok with this as i haven't seen it show up. if it does show up, we can adjust.

@CyrusNajmabadi CyrusNajmabadi requested a review from ToddGrun May 21, 2024 00:40
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 21, 2024 00:57
@CyrusNajmabadi CyrusNajmabadi merged commit 9b1809d into dotnet:main May 21, 2024
25 checks passed
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