-
Notifications
You must be signed in to change notification settings - Fork 850
DI - Cache CallSiteValidator results during walk #2374
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
DI - Cache CallSiteValidator results during walk #2374
Conversation
src/DependencyInjection/DI/src/ServiceLookup/CallSiteValidator.cs
Outdated
Show resolved
Hide resolved
src/DependencyInjection/DI/test/ServiceProviderValidationTests.cs
Outdated
Show resolved
Hide resolved
|
/cc @davidfowl |
| VisitCallSite(callSite, default); | ||
| } | ||
|
|
||
| protected override Type VisitCallSite(ServiceCallSite callSite, CallSiteValidatorState argument) |
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.
Nit - rename argument to state.
| private readonly ConcurrentDictionary<Type, Type> _scopedServices = new ConcurrentDictionary<Type, Type>(); | ||
|
|
||
| // Cache already-checked services that resulted in null. | ||
| private readonly HashSet<Type> _nonScopedServices = new HashSet<Type>(); |
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.
Should we just be using ServiceCacheKey instead? Same for _scoped services?
|
As per aspnet/Announcements#411, we are currently migrating components from this repository to other repositories. This PR targets components that have been moved to dotnet/runtime, in the src/libraries directory. If you're still interested in contributing this change, please retarget your PR to dotnet/runtime and reference the original issue discussing the change or bug fix. If you have questions, or need guidance on how to port your change, please tag |
Caches the results of CallSiteValidator during its walk
Addresses #2353
Performance Comparison
As measured by CallSiteValidatorBenchmark.cs:
Before
After