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

Remove semantic model keep-alive code in completion #73844

Merged

Conversation

ToddGrun
Copy link
Contributor

@ToddGrun ToddGrun commented Jun 4, 2024

There are quite a few providers that don't request/use the semantic model during their computations, and in the case where they are being used to commit / GetDescription, the model would be obtained/calculated unnecessarilly.

I don't believe the keep alive mechanism here is necessary anymore, as Solution.OnSemanticModelObtained caches the model when it's obtained for the active document in the solution.

Additionally, I switched a couple places in CommitManager to use JTF.Runn instead of WaitAndGetResult

There are quite a few providers that don't request/use the semantic model during their computations, and in the case where they are being used to commit / GetDescription, the model would be obtained/calculated unnecessarilly.

I don't believe the keep alive mechanism here is necessary anymore, as Solution.OnSemanticModelObtained caches the model when it's obtained for the active document in the solution.

Additionally, I switched a couple places in CommitManager to use JTF.Runn instead of WaitAndGetResult
@ToddGrun ToddGrun requested a review from a team as a code owner June 4, 2024 20:15
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Jun 4, 2024
@ToddGrun ToddGrun marked this pull request as draft June 5, 2024 19:38
@ToddGrun
Copy link
Contributor Author

ToddGrun commented Jun 5, 2024

Marking as draft as there are test failures

@ToddGrun ToddGrun marked this pull request as ready for review June 6, 2024 12:57
@ToddGrun
Copy link
Contributor Author

ToddGrun commented Jun 6, 2024

@genlu -- ptal. It's not a huge perf improvement, but it does help a bit.

@@ -6923,7 +6923,6 @@ namespace NS2
Dim document = state.Workspace.CurrentSolution.GetDocument(state.Workspace.Documents.Single(Function(d) d.Name = "C.cs").Id)

Dim completionService = document.GetLanguageService(Of CompletionService)()
completionService.GetTestAccessor().SuppressPartialSemantics()
Copy link
Member

Choose a reason for hiding this comment

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

This test involves 2 documents, will using frozen partial cause flakiness? @jasonmalinowski

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jasonmalinowski -- any thoughts here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

def seemsl ike it could. what's the thinking on why this is ok to remove here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't remember exactly why I went down that path, but it doesn't seem necessary for this PR, and probably not a good thing as you both mentioned. Added back.

change = completionService.GetChangeAsync(document, roslynItem, commitCharacter, cancellationToken).WaitAndGetResult(cancellationToken);
_threadingContext.JoinableTaskFactory.Run(async () =>
{
change = await completionService.GetChangeAsync(document, roslynItem, commitCharacter, cancellationToken).ConfigureAwait(false);
Copy link
Member

Choose a reason for hiding this comment

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

ConfigureAwait(true).

Copy link
Member

Choose a reason for hiding this comment

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

same with remainder of code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

@ToddGrun ToddGrun merged commit 5aeb42b into dotnet:main Jun 26, 2024
25 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Jun 26, 2024
JoeRobich added a commit that referenced this pull request Jul 9, 2024
JoeRobich added a commit that referenced this pull request Jul 10, 2024
…changes

Revert "Remove semantic model keep-alive code in completion (#73844)"
@RikkiGibson RikkiGibson modified the milestones: Next, 17.12 P1 Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants