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

Improve performance of FAR #73523

Merged
merged 5 commits into from
May 17, 2024

Conversation

CyrusNajmabadi
Copy link
Member

@CyrusNajmabadi CyrusNajmabadi commented May 16, 2024

While computing the results for FAR we were computing classifications for the reference locations. These were getting dropped, only to be recomputed later when trying to present them in the UI. This is, obviously, terrible.

This drops the time doing a FAR for a widespread symbol (like 'SyntaxToken') from 57 seconds on my machine to 31 seconds.

@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 16, 2024
@CyrusNajmabadi CyrusNajmabadi changed the title WIP: Far perf Improve performance of FAR May 16, 2024
public readonly ImmutableDictionary<string, string> AdditionalProperties = additionalProperties;

public static SerializableSourceReferenceItem Dehydrate(int definitionId, SourceReferenceItem item)
=> new(definitionId,
SerializableDocumentSpan.Dehydrate(item.SourceSpan),
// We're always have classified spans for C#/VB, which are the only languages used in OOP find-references.
SerializableClassifiedSpansAndHighlightSpan.Dehydrate(item.ClassifiedSpans!.Value),
Copy link
Member Author

Choose a reason for hiding this comment

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

the computation always happens here:

var options = await optionsProvider.GetOptionsAsync(document.Project.Services, cancellationToken).ConfigureAwait(false);
var documentSpan = new DocumentSpan(document, sourceSpan);
var classifiedSpans = await ClassifiedSpansAndHighlightSpanFactory.ClassifyAsync(
documentSpan, classifiedSpans: null, options, cancellationToken).ConfigureAwait(false);
return new SourceReferenceItem(
definitionItem, documentSpan, classifiedSpans, referenceLocation.SymbolUsageInfo, referenceLocation.AdditionalProperties);

we just were dropping the value on the floor here.

item.SymbolUsageInfo,
item.AdditionalProperties);

public async Task<SourceReferenceItem> RehydrateAsync(Solution solution, DefinitionItem definition, CancellationToken cancellationToken)
=> new(definition,
await SourceSpan.RehydrateAsync(solution, cancellationToken).ConfigureAwait(false),
// Todo: consider serializing this over.
Copy link
Member Author

Choose a reason for hiding this comment

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

yes. this was a good thing to consider :D

/// </summary>
#pragma warning disable IDE0052 // Remove unread private members
private readonly SemanticModel _nullableEnabledSemanticModel;
#pragma warning restore IDE0052 // Remove unread private members
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 is part of the change. ideally nothing will be using nullable-enabled-semantic-model (And i want to stamp out anything that is using it). but if they do, this at least means we cache the results while processing the doc.

Copy link
Member Author

Choose a reason for hiding this comment

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

next week i'll be setting BPs in the normal 'get semantic model' codepath so that i can update any final services still using it during FAR to stop.

@CyrusNajmabadi CyrusNajmabadi marked this pull request as ready for review May 16, 2024 22:31
@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner May 16, 2024 22:31
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 merged commit 7a56c5e into dotnet:main May 17, 2024
25 checks passed
@CyrusNajmabadi CyrusNajmabadi deleted the farAndClassifiedSpans branch May 17, 2024 00:15
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone May 17, 2024
@Cosifne Cosifne modified the milestones: Next, 17.11 P2 May 28, 2024
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