Eliminate array allocations in CustomAttribute.IsDefined() overloads#2632
Eliminate array allocations in CustomAttribute.IsDefined() overloads#2632jack-pappas wants to merge 4 commits into
Conversation
Implemented struct enumerable and corresponding enumerator wrapping MetadataImport and MetadataEnumResult. Replaced CustomAttributeData.GetCustomAttributeRecords(RuntimeModule, int) with a new method returning a value of the new struct enumerable type; modified call sites of the old method to use the new method and structs instead. This eliminates unnecessary, short-lived CustomAttributeRecord[] allocations which resulted from calling any of the CustomAttribute.IsDefined() overloads.
|
@dotnet-bot test Ubuntu x64 Release Build and Test |
|
@dotnet-bot test OSX x64 Release Build and Test |
|
@ellismg I've updated the PR per your comments. Uses of the |
|
Also -- I signed a CLA several months ago, why does @dnfclas think I haven't? Just to be certain, I signed the CLA again and have received the approval email (from the CLA admin). |
|
@jack-pappas, Thanks for signing the contribution license agreement so quickly! Actual humans will now validate the agreement and then evaluate the PR. |
|
Please disregard my last comment -- turns out I'd signed the Microsoft CLA before, not the new .NET Foundation CLA. |
|
@stephentoub Would you mind taking a look at this? I believe it's ready to be merged. |
|
Could you please shared any numbers on what it is improving? (see discussion in #3849 on what I am looking for) |
|
I applied this to #6645 and the performance regressed slightly :( |
|
So where do we sit on this one? @jack-pappas , can you provide some concrete numbers showing the benefits realized by the change? If there is no forward motion with the PR, we should close it until we're ready to actively work through the data and finish it up. |
|
I'll run some benchmarks this weekend to try to get some results so we can make a decision one way or the other on this. I also want to poke around a bit to try to figure out what might've caused the code to be slower when @benadams tried it. |
|
Closing old inactive PRs. @jack-pappas please feel free to resubmit if you get a chance to finish this. Thanks! |
|
It doesn't currently allocate for enum ToString anymore so that might have been why I saw a regression (uses Array.Empty) |
Implemented struct enumerable and corresponding enumerator wrapping
MetadataImportandMetadataEnumResult.Replaced
CustomAttributeData.GetCustomAttributeRecords(RuntimeModule, int)with a new method returning a value of the new struct enumerable type (CustomAttributeRecordCollection); modified call sites of the old method to use the new method and structs instead.These changes eliminate the short-lived
CustomAttributeRecord[]allocations which currently result from calling any of theCustomAttribute.IsDefined()overloads.