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

Reduce heap allocations in ResolverUtility.FindLibraryByVersionAsync #11409

Closed
kartheekp-ms opened this issue Nov 23, 2021 · 2 comments · Fixed by NuGet/NuGet.Client#4348
Closed
Assignees
Labels
Area:Analyzers Category:Quality Week Issues that should be considered for quality week PerfWins Tenet:Performance Performance issues Type:Bug

Comments

@kartheekp-ms
Copy link
Contributor

@kartheekp-ms commented on Tue Nov 23 2021

While working on https://github.com/nuget/client.engineering/issues/1057 issue, I noticed that ResolverUtility.FindLibraryByVersionAsync method https://github.com/NuGet/NuGet.Client/blob/a8b6b1fb3a1bccd207a83612cd0f5e1f4ff1d0b8/src/NuGet.Core/NuGet.DependencyResolver.Core/ResolverUtility.cs#L363 has following warnings reported by the PerformanceSensitive analyzers.

Severity Code Description Project File Line Suppression State
Warning HAA0302 The compiler will emit a class that will hold this as a field to allow capturing of this closure NuGet.DependencyResolver.Core (net472) ~\NuGet.Client-W1\src\NuGet.Core\NuGet.DependencyResolver.Core\ResolverUtility.cs 365 Active
Warning HAA0301 Heap allocation of closure Captures: libraryRange,framework,cacheContext,logger,token NuGet.DependencyResolver.Core (net472) ~\NuGet.Client-W1\src\NuGet.Core\NuGet.DependencyResolver.Core\ResolverUtility.cs 373 Active
Warning HAA0302 The compiler will emit a class that will hold this as a field to allow capturing of this closure NuGet.DependencyResolver.Core (net472) ~\NuGet.Client-W1\src\NuGet.Core\NuGet.DependencyResolver.Core\ResolverUtility.cs 423 Active

This method has ~880 MB allocations during solution restore for OrchardCore solution https://github.com/OrchardCMS/OrchardCore/tree/75923732c36d2785cb869affb805f0ff19d1847c

image

@aortiz-msft
Copy link
Contributor

@kartheekp-ms - Would you please get us memory allocations before and after this change?

@kartheekp-ms
Copy link
Contributor Author

kartheekp-ms commented Dec 2, 2021

@aortiz-msft - The heap allocations have reduced by 200 MB after the fix for OrchardCore solution restore scenario. I added more details to the PR description. NuGet/NuGet.Client#4348

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area:Analyzers Category:Quality Week Issues that should be considered for quality week PerfWins Tenet:Performance Performance issues Type:Bug
Projects
None yet
3 participants