dotnet / linker

388 stars 127 forks source link

Use LinkContext caching when resolving ExportedTypes #3075

Closed jtschuster closed 1 year ago

jtschuster commented 1 year ago

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 https://github.com/dotnet/linker/pull/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 https://github.com/dotnet/linker/issues/3067 87310 in main 23520 after https://github.com/dotnet/linker/pull/3073 + this change