Skip to content

Conversation

@jtschuster
Copy link
Member

@jtschuster jtschuster commented Oct 18, 2022

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

{
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.")]
Copy link
Contributor

Choose a reason for hiding this comment

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

  • Please use pragma
  • Would it be too ugly to pass the context to GetDisplayName?

Copy link
Member Author

Choose a reason for hiding this comment

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

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.

Copy link
Member

@sbomer sbomer left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

@marek-safar marek-safar merged commit add4655 into dotnet:main Oct 20, 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
agocke pushed a commit to dotnet/runtime that referenced this pull request Nov 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants