-
Notifications
You must be signed in to change notification settings - Fork 47
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
Add optimisation for reflection-activated components to avoid adding a parameter in the resolve path if possible. #119
Conversation
…a parameter in the resolve path.
… level rather than service.
src/Autofac.Extensions.DependencyInjection/AutofacRegistration.cs
Outdated
Show resolved
Hide resolved
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #119 +/- ##
===========================================
+ Coverage 88.70% 90.69% +1.98%
===========================================
Files 16 15 -1
Lines 310 344 +34
Branches 57 69 +12
===========================================
+ Hits 275 312 +37
+ Misses 22 20 -2
+ Partials 13 12 -1 ☔ View full report in Codecov by Sentry. |
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.
I think we can drop the delegate support to make this a touch faster; and if the unit test can be added to satisfy coverage, I think we're good to go.
src/Autofac.Extensions.DependencyInjection/AutofacRegistration.cs
Outdated
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.
🐲
The issue this was raised against contains an extremely deep resolve graph, but it does show there's a considerable overhead to changing the request parameters even if a type has no keyed service parameters.
Basically, when components are registering we'll "look ahead" at all the constructors for reflection activation, and if none of them have a
FromKeyedService
attribute, we can skip adding the additional parameter in the new middleware.I've also moved the middleware to the start of the activation phase of the component pipeline, because there's no point adding the parameters if we've already instantiated a shared component.
Point of Debate
@tillig, one question for you is in the review comment, about whether we need to support a certain esoteric use-case; if not then we get to stay fast in the delegate component path.
Closes #118
Benchmarks
This is the same slightly extreme benchmark used to raise #118
v8
v9
This branch