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

Make finding checksum async #40091

Merged
merged 4 commits into from
Dec 5, 2019
Merged

Make finding checksum async #40091

merged 4 commits into from
Dec 5, 2019

Conversation

tmat
Copy link
Member

@tmat tmat commented Dec 2, 2019

When we retrieve an object for Text checksum in DocumentStateChecksums we used a trick to avoid making Find asynchronous and save Task allocations. We placed DocumentState to the result instead of the expected SourceText and retrieved the actual SourceText instance later on, when we were in async context. We can avoid the Task allocations by using ValueTask, remove this special casing and simplify SolutionAsset implementation.

Add nullable annotations.

Move methods from Microsoft.CodeAnalysis.Remote.Shared.Extensions to TestUtils as they are only used for testing.

Remove SolutionAssetManager and RemoteHostPanel. They were only used for experimenting and are no longer needed.

Copy link
Member

@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.

20/27 files reviewed so far

@tmat
Copy link
Member Author

tmat commented Dec 3, 2019

@sharwell Would we want TextDocumentState.GetTextAsync to use ValueTask to avoid Task allocation when it completes synchronously?

@sharwell
Copy link
Member

sharwell commented Dec 3, 2019

Would we want TextDocumentState.GetTextAsync to use ValueTask to avoid Task allocation when it completes synchronously?

The overwhelming use of this method enters through TextDocument.GetTextAsync. Since that implementation delegates (as opposed to wrapping the call in its own async method), there will be an unavoidable task allocation regardless of the return type in TextDocumentState.

FWIW, TextDocument.GetTextAsync has definitely shown up on my list of async methods that would benefit from ValueTask<T>. The only reason it isn't converted is we need to find a pattern for handling public APIs.

@tmat
Copy link
Member Author

tmat commented Dec 3, 2019

The overwhelming use of this method enters through TextDocument.GetTextAsync. Since that implementation delegates (as opposed to wrapping the call in its own async method), there will be an unavoidable task allocation regardless of the return type in TextDocumentState

That's true, but making TextDocumentState.GetTextAsync would at least avoid some allocations until we figure out the new public API.

@tmat tmat closed this Dec 3, 2019
@tmat tmat reopened this Dec 3, 2019
@tmat tmat marked this pull request as ready for review December 4, 2019 01:37
@tmat tmat requested a review from a team as a code owner December 4, 2019 01:37
@tmat
Copy link
Member Author

tmat commented Dec 4, 2019

@dotnet/roslyn-ide PTAL

@tmat tmat merged commit 6a14f26 into dotnet:master Dec 5, 2019
@tmat tmat deleted the Checksums branch December 5, 2019 00:51
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