Skip to content

Share SyntaxContext among all internal CompletionProviders#61057

Merged
genlu merged 2 commits intodotnet:mainfrom
genlu:InternalSyntaxContextCache
May 10, 2022
Merged

Share SyntaxContext among all internal CompletionProviders#61057
genlu merged 2 commits intodotnet:mainfrom
genlu:InternalSyntaxContextCache

Conversation

@genlu
Copy link
Member

@genlu genlu commented Apr 29, 2022

via CompletionContext during a completion session to reduce repeat computation.

Fixes AB#1460014

@genlu genlu requested a review from a team as a code owner April 29, 2022 23:29
@ghost ghost added the Area-IDE label Apr 29, 2022
@genlu genlu requested a review from sharwell May 5, 2022 23:30
Copy link
Contributor

@sharwell sharwell left a comment

Choose a reason for hiding this comment

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

Overall looks good, but need to optimize the fast path for the comments marked with ❗

@genlu genlu force-pushed the InternalSyntaxContextCache branch from c6167af to 92b54e9 Compare May 9, 2022 21:47
via CompletionContext during a completion session to reduce repeat computation.
@genlu genlu force-pushed the InternalSyntaxContextCache branch from 92b54e9 to 7dc3c66 Compare May 9, 2022 21:51
@genlu genlu force-pushed the InternalSyntaxContextCache branch from 9123da7 to fa2553a Compare May 9, 2022 23:50
Copy link
Contributor

@CyrusNajmabadi CyrusNajmabadi left a comment

Choose a reason for hiding this comment

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

Thanks!

@genlu genlu force-pushed the InternalSyntaxContextCache branch from fa2553a to 364d352 Compare May 10, 2022 00:02
@genlu genlu enabled auto-merge May 10, 2022 00:02
return _cache.GetOrAdd(document, d => AsyncLazy.Create(cancellationToken
=> CompletionHelper.CreateSyntaxContextWithExistingSpeculativeModelAsync(document, position, cancellationToken), cacheResult: true));
// Extract a local function to avoid creating a closure for code path of cache hit.
AsyncLazy<SyntaxContext> GetLazySyntaxContextWithSpeculativeModel(Document document)
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Best to make this a static local function to guarantee the lack of a closure. The caller can pass this to a parameter named self.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, will clean this up in a new PR

@genlu genlu merged commit 5adf960 into dotnet:main May 10, 2022
@ghost ghost added this to the Next milestone May 10, 2022
@genlu genlu deleted the InternalSyntaxContextCache branch May 10, 2022 16:16
@Cosifne Cosifne modified the milestones: Next, 17.3 P2 May 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants