Skip to content

Make finding checksum async#40091

Merged
tmat merged 4 commits intodotnet:masterfrom
tmat:Checksums
Dec 5, 2019
Merged

Make finding checksum async#40091
tmat merged 4 commits intodotnet:masterfrom
tmat:Checksums

Conversation

@tmat
Copy link
Copy Markdown
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
Copy Markdown
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.

20/27 files reviewed so far

Comment thread src/VisualStudio/Core/Def/Implementation/Remote/RemotableDataJsonRpcEx.cs Outdated
Comment thread src/VisualStudio/Core/Test.Next/Services/SolutionServiceTests.cs
Comment thread src/Workspaces/Core/Portable/Execution/AssetStorages.cs Outdated
Comment thread src/Workspaces/Core/Portable/Utilities/LazyInitialization.cs Outdated
Comment thread src/Workspaces/Core/Portable/Workspace/Solution/StateChecksums.cs Outdated
Comment thread src/Workspaces/Core/Portable/Workspace/Solution/StateChecksums.cs Outdated
Comment thread src/Workspaces/Core/Portable/Workspace/Solution/StateChecksums.cs Outdated
Comment thread src/Workspaces/Core/Portable/Workspace/Solution/StateChecksums.cs Outdated
Comment thread src/Workspaces/Core/Portable/Workspace/Solution/StateChecksums.cs Outdated
@tmat
Copy link
Copy Markdown
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
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
Member Author

tmat commented Dec 4, 2019

@dotnet/roslyn-ide PTAL

Comment thread src/Workspaces/Core/Portable/Execution/AssetStorages.Storage.cs
Comment thread src/Workspaces/Core/Portable/Execution/AssetStorages.Storage.cs Outdated
Comment thread src/Workspaces/Core/Portable/Execution/AssetStorages.cs Outdated
Comment thread src/Workspaces/Core/Portable/Utilities/LazyInitialization.cs Outdated
Comment thread src/Workspaces/Core/Portable/Utilities/LazyInitialization.cs Outdated
Comment thread src/Workspaces/Core/Portable/Utilities/LazyInitialization.cs Outdated
Comment thread src/Workspaces/Core/Portable/Workspace/Solution/StateChecksums.cs
@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