Use LinkContext caching when resolving ExportedTypes#3075
Merged
marek-safar merged 5 commits intodotnet:mainfrom Oct 20, 2022
Merged
Use LinkContext caching when resolving ExportedTypes#3075marek-safar merged 5 commits intodotnet:mainfrom
marek-safar merged 5 commits intodotnet:mainfrom
Conversation
marek-safar
reviewed
Oct 19, 2022
| { | ||
| public static class MethodReferenceExtensions | ||
| { | ||
| [System.Diagnostics.CodeAnalysis.SuppressMessage ("ApiDesign", "RS0030:Do not used banned APIs", Justification = "MethodReference.Resolve is banned for performance reasons. GetDisplayName should be a really cold path and shouldn't require a context to call.")] |
Contributor
There was a problem hiding this comment.
- Please use pragma
- Would it be too ugly to pass the context to GetDisplayName?
Member
Author
There was a problem hiding this comment.
It might not necessarily be ugly, but I think it would take significant effort to bubble up the context parameter to GetDisplayName on all the SingleValue types and TypeSystemProxy types, and it's really only called from diagnostics which should be a very cold path anyway.
sbomer
reviewed
Oct 19, 2022
jtschuster
added a commit
to jtschuster/linker
that referenced
this pull request
Oct 21, 2022
tlakollo
pushed a commit
to tlakollo/runtime
that referenced
this pull request
Oct 27, 2022
) Commit migrated from dotnet/linker@add4655
agocke
pushed a commit
to dotnet/runtime
that referenced
this pull request
Nov 16, 2022
) Commit migrated from dotnet/linker@add4655
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When profiling ASP.Net benchmark builds, I found significant time was being spent resolving
ExportedType's since we don't have a cache for those like we do for TypeReference and MethodReference.
Bans MethodReference.Resolve and ExportedType.Resolve and recommend LinkContext.Resolve instead (except in SweepStep).
Adds a cache on LinkContext for resolving ExportedTypes and replaces calls to Cecil's Resolve.
Replaces some calls to MethodReference.Resolve.
Together with #3073, performance improves to better than before the virtual method regression in August.
Trimmer CPU milliseconds on ASP.Net benchmarks build:
27325 before the regression related to #3067
87310 in main
23520 after #3073 + this change