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

Avoid unnecessary array+linq allocs in common case #73727

Merged
merged 3 commits into from
May 27, 2024

Conversation

CyrusNajmabadi
Copy link
Member

Addresses large allocation here:

image

The issue is not the array allocation itself, it's that we're doing anything allocating for a very common case where we're called to update a document with the text it already points at. This can happen during things like GetOpenDocumentWithChanges:

image

In hte majority of cases, the doc will be updated to the content it already has. So bailing out immediately, without doing any work is beneficial.

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner May 26, 2024 21:20
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels May 26, 2024
// the same text (for example, when GetOpenDocumentInCurrentContextWithChanges) is called.
//
// The use of GetRequiredState mirrors what happens in WithDocumentTexts
if (!SourceTextIsUnchanged(documentState, text))
Copy link
Contributor

Choose a reason for hiding this comment

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

if (!SourceTextIsUnchanged(documentState, text))

Sorry, another question.

Is there usually only a single documentId that will end up calling WithDocumentTexts? (if multiple will, it seems like they should be batched together)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. That definitely makes sense. I can tweak to that when I get home. Lmk if this is otherwise ok

Copy link
Member Author

Choose a reason for hiding this comment

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

done.

Copy link
Contributor

@ToddGrun ToddGrun left a comment

Choose a reason for hiding this comment

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

:shipit:

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.

3 participants