Skip to content

Avoid realizing documents in DiagnosticDataSerializer#49081

Merged
sharwell merged 2 commits intodotnet:masterfrom
sharwell:use-document-states
Oct 31, 2020
Merged

Avoid realizing documents in DiagnosticDataSerializer#49081
sharwell merged 2 commits intodotnet:masterfrom
sharwell:use-document-states

Conversation

@sharwell
Copy link
Contributor

This change gives a 25% performance improvement for a recent internal trace.

@sharwell sharwell requested a review from a team as a code owner October 30, 2020 19:27
var documentId = document != null
? document.Id
: project.Documents.FirstOrDefault(d => d.FilePath == originalFile)?.Id;
: project.State.DocumentStates.FirstOrDefault(d => d.Value.FilePath == originalFile).Key;
Copy link
Member

Choose a reason for hiding this comment

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

Why isn't this just calling Solution.GetDocumentIdsByFilePath()? Then we're not using internal implementation details, and it's also not O(n).

Copy link
Member

Choose a reason for hiding this comment

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

(we can still filter down to the IDs from the given project to avoid linked file issues)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why isn't this just calling Solution.GetDocumentIdsByFilePath

I had no idea it existed 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

➡️ Now updated

@sharwell sharwell changed the title Use document states to avoid realizing documents in DiagnosticDataSerializer Avoid realizing documents in DiagnosticDataSerializer Oct 30, 2020
@sharwell sharwell merged commit 097e4ad into dotnet:master Oct 31, 2020
@ghost ghost added this to the Next milestone Oct 31, 2020
@sharwell sharwell deleted the use-document-states branch October 31, 2020 00:27
@allisonchou allisonchou modified the milestones: Next, 16.9.P2 Nov 24, 2020
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.

6 participants