-
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
Performance Degradation in version 9.0.0 #118
Comments
Here's a zip of the benchmark project I used. The code above was copy/pasted piecemeal and might have small issues here or there. |
Hi @andrewaramsay, just to confirm that I can recreate your results locally;
Good find, and thank you for raising; I'll try to investigate this, and suspect you're right about keyed services being to blame; the challenge we'll likely have is simply that adding support for MSDI-style keyed services will slow down Autofac, because we are required to do more work. In addition to the list allocation, likely candidates for the resolve overhead are the call to I'll have to experiment here with options for reducing the overhead. |
Describe the bug
There is a significant performance degradation introduced in version 9.0.0 that was not present in 8.0.0. My traces led me to KeyedServiceMiddleware line 22 as suspect. As further evidence that the issue comes from this change, if I do not call
Populate
and just useAutofacServiceProvider
directly, this line of code is not executed and the performance issues are not observed. This is obviously, not a suitable workaround, as it defeats half the purpose of this library, but is useful troubleshooting information.These reproduction steps are in a benchmark, but we also witnessed this issue as about a 2x increase in CPU utilization and eventual application failure in a full fledged application while undergoing performance stress testing.
To reproduce
Reproduction of the issue, ideally in a unit test format.
ContainerBuilder
.ServiceCollection
, register some arbitrary service, and callPopulate
to load it into the container builder.KeyedServiceMiddleware
to be added to the resolve pipeline.AutofacServiceProvider
using the built container.Full exception with stack trace:
Assembly/dependency versions:
Additional context
Benchmark results (sorry it's a screenshot, I don't have the console output on hand right now)
The text was updated successfully, but these errors were encountered: