Skip to content

Reduce AssemblyName allocations#2676

Merged
cdmihai merged 9 commits intodotnet:vs15.5from
cdmihai:reduceAssemblyNameAllocations
Nov 6, 2017
Merged

Reduce AssemblyName allocations#2676
cdmihai merged 9 commits intodotnet:vs15.5from
cdmihai:reduceAssemblyNameAllocations

Conversation

@cdmihai
Copy link
Copy Markdown
Contributor

@cdmihai cdmihai commented Oct 26, 2017

In mvc rebuild (133mb total allocations), reduces AssemblyName allocations 18.3% -> 0.5% and AssemblyNameExtensions 4.5% -> 0.3%. In a Roslyn rebuild (3.2gb total allocations), it reduces AssemblyName 2.3% -> 0.2% and AsssemblyNameExtension 0.6% -> 0.1%.

Commit #1 is safe to do, because the AssemblyName was double cloned ...
Commit #2 replaces calls to AssemblyNameExtension.EqualsImpl and AssemblyNameExtension.CompareBaseNameToImpl with a simple name, culture, and key comparison. This looks safe to do because:

This reduces 1% of Roslyn rebuild allocations, and ~4% of dotnet new mvc
allocations.

It is safe to remove the call to clone, because PartialAssemblyName also
clones it.
@cdmihai cdmihai changed the title Reduce assembly name allocations Reduce AssemblyName allocations Oct 26, 2017
Otherwise it leads to wasted time when analyzing memory perf.
Comment thread src/Shared/AssemblyNameExtension.cs Outdated
}

return true;
return a?.CultureInfo?.LCID == b?.CultureInfo?.LCID;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This isn't the same comparison as before - if one is Invariant and one is null, this used to return true, now it returns false.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You're right. I made the .net core implementation follow the full framework one and not the other way around

Since the full framework comparison was there first, it's the "more correct" one relative to the rest of the code.
@cdmihai
Copy link
Copy Markdown
Contributor Author

cdmihai commented Oct 27, 2017

Apparently BuildEnvironmentHelper.Instance.RunningTests does not work on .net core :(. Looking into it.

#endif

[Fact]
public void ShouldBeRunningInTests()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Best kind of bugfix. :)

@davkean
Copy link
Copy Markdown
Member

davkean commented Nov 2, 2017

Can we get this merged in?

@AndyGerlicher
Copy link
Copy Markdown
Contributor

Will submit this plus the others on Monday for escrow.

@cdmihai cdmihai merged commit 9d0b4e6 into dotnet:vs15.5 Nov 6, 2017
@cdmihai cdmihai deleted the reduceAssemblyNameAllocations branch April 26, 2018 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants