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

MSBuildNameIgnoreCaseComparer is allocating 1% of a solution-wide design-time build #2434

Closed
davkean opened this issue Aug 16, 2017 · 2 comments · Fixed by #2549
Closed

MSBuildNameIgnoreCaseComparer is allocating 1% of a solution-wide design-time build #2434

davkean opened this issue Aug 16, 2017 · 2 comments · Fixed by #2549

Comments

@davkean
Copy link
Member

davkean commented Aug 16, 2017

From here: dotnet/project-system#2712.

Looking at history, in particular, #cc1e115c it looks by design that you are creating lots of these:
image

@davkean davkean changed the title MSBuildNameIgnoreCaseComparer is 1% of a solution-wide design-time build MSBuildNameIgnoreCaseComparer is allocating 1% of a solution-wide design-time build Aug 16, 2017
@davkean
Copy link
Member Author

davkean commented Sep 25, 2017

We're boxing IKeyed here:
image

@davkean
Copy link
Member Author

davkean commented Sep 27, 2017

I'm tracking the KeyedObject boxing here: #2561.

radical pushed a commit to mono/msbuild that referenced this issue Oct 25, 2017
Fixes: dotnet#2434
Partially fixes: dotnet#2429

This change converts MSBuildNameIgnoreCaseComparer to a stateless comparer by implementing IConstrainedEqualityComparer, this avoids:

1. Creating a new comparer for every collection (saves ~1% of allocations)
2. Locking within Equals/GetHashCode (saves ~0.2% of allocations)

This saves approx 300ms running a design time build over the project called out in dotnet/project-system#2789.
@AR-May AR-May added the triaged label Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants