Optimize IsRecord for non-record fast paths#48935
Conversation
We noticed some perf regressions when SymbolDisplayVisitor was calling IsRecord for a lot of types. This attempts to reduce the memory impact by having PEMethodSymbol.IsRecord first check to see if any member is named <Clone>$, and not loading the full signatures of all members.
|
Test insertion signed build: https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=4178241&view=results |
|
I have a fix for this in SymbolDisplayVisitor in progress, which will not hurt to have both. If this one works though, it's certainly cleaner than mine. |
@sharwell I don't believe a fix for this in |
|
It appears this fixes the BytesAllocated scenario that we were concerned about but I noticed a new RefSet_Image_Delta Regression instead in a different scenario. I don't see how it could be related to this change, but I'm not extremely experienced with the tools. |
|
@RikkiGibson the refset regression is likely due to the CLR methods jitting regressions. |
|
Hello @333fred! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
dotnet#48935 optimizes one path that hits FindValidCloneMethod, but there are others that could do with the same fast-path optimization. In order to accomplish that, I introduced a new HasPossibleCloneMethod on NamedTypeSymbol, that returns whether the type _could_ have a method on it that is a valid clone method. For source types, this is a quick syntax check to see if it's a record. For metadata types, it's a check on just the member names for something with the right name. This should prevent us from unnecessarily loading all method signatures from metadata unnecessarily whenever we check for a clone method.
We noticed some perf regressions when SymbolDisplayVisitor was calling IsRecord for a lot of types. This attempts to reduce the memory impact by having PEMethodSymbol.IsRecord first check to see if any member is named
<Clone>$, and not loading the full signatures of all members.