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 array enumerator allocations in SimpleDiagnostic.Equals #69238

Merged
merged 1 commit into from
Jul 31, 2023

Conversation

sharwell
Copy link
Member

@sharwell sharwell commented Jul 26, 2023

Fixes 88GB allocations observed in an 80 second performance trace for the VS testing team. The allocations originated from this line:

&& _messageArgs.SequenceEqual(other._messageArgs, (a, b) => a == b)

Fixes 88GB allocations observed in an 80 second performance trace for
the VS testing team.
@sharwell sharwell requested a review from a team as a code owner July 26, 2023 15:49
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Jul 26, 2023
@sharwell
Copy link
Member Author

@dotnet/roslyn-compiler for reviews

@@ -153,6 +153,29 @@ internal static int BinarySearch(this int[] array, int value)
return ~low;
}

public static bool SequenceEqual<T>(this T[]? first, T[]? second, Func<T, T, bool> comparer)
{
RoslynDebug.Assert(comparer != null);
Copy link
Member

Choose a reason for hiding this comment

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

RoslynDebug.Assert

Debug.Assert(...)?

Copy link
Member Author

Choose a reason for hiding this comment

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

➡️ RoslynDebug.Assert is the null-annotated form of this invocation.

@sharwell sharwell merged commit 745dd17 into dotnet:main Jul 31, 2023
@sharwell sharwell deleted the array-equal branch July 31, 2023 13:58
@ghost ghost added this to the Next milestone Jul 31, 2023
@dibarbet dibarbet modified the milestones: Next, 17.8 P2 Aug 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers 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.

6 participants