-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Improve performance of FAR #73523
Conversation
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), |
There was a problem hiding this comment.
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:
roslyn/src/Features/Core/Portable/FindUsages/DefinitionItemFactory.cs
Lines 303 to 310 in cdbed67
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. |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.