-
-
Notifications
You must be signed in to change notification settings - Fork 836
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Single constructor reflection optimisation #1325
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #1325 +/- ##
===========================================
+ Coverage 77.69% 77.80% +0.10%
===========================================
Files 190 190
Lines 5412 5488 +76
Branches 1084 1097 +13
===========================================
+ Hits 4205 4270 +65
- Misses 705 710 +5
- Partials 502 508 +6
Continue to review full report at Codecov.
|
…o change the CheckDispose method to allow inlining of the check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple minor things, question about whether we should change the IConstructorSelector
interface.
Added |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good. Only real question of substance is about whether IConstructorSelectorWithEarlyBinding
should inherit IConstructorSelector
.
src/Autofac/Core/Activators/Reflection/IConstructorSelectorWithEarlyBinding.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚨
Would it be because the multi-contructors still have dependencies, and those dependencies have single constructors which are now optimized? |
Yes, that's also quite possible; I didn't really investigate the reason that closely. |
We didn't actually need to generate extra delegates using the mechanism added in #1321, I've added fast-paths through the reflection activator for single-constructor and matched-sig-constructor selection that does "early binding" of sorts on the constructors where possible.
The approach taken actually means I don't need to change the binding exception handling at all, and the existing resolve check behaviour stays.
We get noticeable perf and memory usage improvements across the board.
Some examples:
DeepGraphResolveBenchmark
ChildScopeResolveBenchmark
EnumerableResolveBenchmark
Multi-Constructor Benchmarks
Improvements on the multi-constructor benchmarks (which use the old path) may be down to the use of the
ReferenceEquals
check against theNoParameters
constant, rather thanAny()
.