Warm up ImportCompletion cache in background when opening a document#55729
Merged
genlu merged 6 commits intodotnet:mainfrom Aug 30, 2021
Merged
Warm up ImportCompletion cache in background when opening a document#55729genlu merged 6 commits intodotnet:mainfrom
genlu merged 6 commits intodotnet:mainfrom
Conversation
...ortable/Completion/Providers/ImportCompletionProvider/AbstractTypeImportCompletionService.cs
Outdated
Show resolved
Hide resolved
src/VisualStudio/CSharp/Impl/LanguageService/CSharpCreateServicesOnTextViewConnection.cs
Outdated
Show resolved
Hide resolved
Member
Author
|
@CyrusNajmabadi @sharwell Please take a look, thanks! |
sharwell
reviewed
Aug 27, 2021
| if (s_cachingTask.IsCompleted) | ||
| { | ||
| s_cachingTask = Task.Run(() => GetCacheEntriesAsync(currentProject, syntaxContext, forceCacheCreation: true, CancellationToken.None)); | ||
| // When building cache in the background, make sure we always use latest snapshot with full semantic |
Contributor
There was a problem hiding this comment.
❔ Can we make the call twice? First time uses partial semantics to get a mostly-correct cache quickly, and then before returning it waits for full semantics?
sharwell
reviewed
Aug 27, 2021
Comment on lines
+66
to
+67
| _typeTask = _typeTask.ContinueWith(_ => PopulateTypeImportCompletionCacheAsync(this.Workspace.CurrentSolution.GetDocument(documentId)), TaskScheduler.Default); | ||
| _extensionMethodTask = _extensionMethodTask.ContinueWith(_ => PopulateExtensionMethodImportCompletionCacheAsync(this.Workspace.CurrentSolution.GetDocument(documentId)), TaskScheduler.Default); |
Contributor
There was a problem hiding this comment.
❔ Why is this using task chains instead of just two local variables?
Member
Author
There was a problem hiding this comment.
To avoid the backgrounds tasks taking up too much resources calculating the cache if user opened a lot of files.
sharwell
reviewed
Aug 27, 2021
...mpletion/Providers/ImportCompletionProvider/IRemoteExtensionMethodImportCompletionService.cs
Outdated
Show resolved
Hide resolved
sharwell
reviewed
Aug 27, 2021
...ortCompletionProvider/ExtensionMethodImportCompletionHelper.ExtensionMethodSymbolComputer.cs
Outdated
Show resolved
Hide resolved
sharwell
reviewed
Aug 27, 2021
...ortCompletionProvider/ExtensionMethodImportCompletionHelper.ExtensionMethodSymbolComputer.cs
Outdated
Show resolved
Hide resolved
sharwell
reviewed
Aug 27, 2021
| if (s_cachingTask.IsCompleted) | ||
| { | ||
| s_cachingTask = Task.Run(() => GetCacheEntriesAsync(currentProject, syntaxContext, forceCacheCreation: true, CancellationToken.None)); | ||
| // When building cache in the background, make sure we always use latest snapshot with full semantic |
Contributor
There was a problem hiding this comment.
💭 It seems like a future change could consolidate the calculation strategies for these two similar services. I definitely do not want to include it here (where it would delay a big improvement).
sharwell
approved these changes
Aug 27, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #37197