autofac / Autofac

An addictive .NET IoC container
https://autofac.org
MIT License
4.44k stars 836 forks source link

Optimization: Memoize `RequiredMemberAttribute` search #1415

Closed SergeiPavlov closed 4 months ago

SergeiPavlov commented 4 months ago

We see in Profiler that .GetCustomAttribute() is a hotspot. Memoizing it will improve performance.

image

SergeiPavlov commented 4 months ago

I see this will not work because of "Unloading feature" CanLoadInstanceOfAssemblyAndUnloadItAfterOnActivatedInModule test

tillig commented 4 months ago

We have all of the reflection-related caches centralized to allow for unloading assembly load contexts. I'm guessing that's why some of those tests are failing.

codecov[bot] commented 4 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 78.52%. Comparing base (b843130) to head (3fe2ddf).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## develop #1415 +/- ## =========================================== + Coverage 78.48% 78.52% +0.03% =========================================== Files 200 200 Lines 5703 5713 +10 Branches 1168 1168 =========================================== + Hits 4476 4486 +10 Misses 714 714 Partials 513 513 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

SergeiPavlov commented 4 months ago

Thank you. Refactored to use ReflectionCacheSet