Skip to content

Performance improvements#1478

Merged
tillig merged 13 commits intodevelopfrom
feature/perf
Mar 12, 2026
Merged

Performance improvements#1478
tillig merged 13 commits intodevelopfrom
feature/perf

Conversation

@tillig
Copy link
Copy Markdown
Member

@tillig tillig commented Mar 12, 2026

After adding AnyKey support it seemed like the benchmarks were starting to slip from the last major release. I did some passes through the code to find some performance/maintainability wins to try to claw back some of that perf.

  • Performance-focused refactor across resolve pipeline and middleware to reduce per-resolve overhead and trim hot-path allocations.
  • Removed several LINQ-based paths in critical resolution/injection flows and replaced them with lower-overhead logic.
  • Added and improved caching for AnyKey and adapted AnyKey registrations, including per-scope cache behavior.
  • Added support for externally managed reflection caches and expanded reflection cache dictionary handling for keyed services/parameters.
  • Optimized reflection activation and keyed service parameter injection to skip unnecessary work when possible.
  • Updated benchmark coverage with additional AnyKey scenarios and benchmark-set updates to verify performance impact.
  • Included cleanup and stability updates (for example, removing unused usings and reverting temporary audit configuration changes).
  • Validation completed with test and benchmark runs during development.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 12, 2026

Codecov Report

❌ Patch coverage is 56.95364% with 65 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.42%. Comparing base (812f644) to head (7b3a2c8).
⚠️ Report is 14 commits behind head on develop.

Files with missing lines Patch % Lines
.../Core/Resolving/Pipeline/ResolvePipelineBuilder.cs 0.00% 48 Missing and 1 partial ⚠️
...Middleware/CircularDependencyDetectorMiddleware.cs 55.55% 2 Missing and 2 partials ⚠️
...til/Cache/ReflectionCacheKeyedServiceDictionary.cs 63.63% 2 Missing and 2 partials ⚠️
src/Autofac/Core/ReflectionCacheSet.cs 87.50% 1 Missing and 1 partial ⚠️
...ing/Middleware/ActivatorErrorHandlingMiddleware.cs 75.00% 1 Missing and 1 partial ⚠️
...Features/KeyedServices/AnyKeyRegistrationSource.cs 84.61% 1 Missing and 1 partial ⚠️
src/Autofac/Core/KeyedServiceParameterInjector.cs 85.71% 0 Missing and 1 partial ⚠️
...c/Core/Resolving/Middleware/StartableMiddleware.cs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1478      +/-   ##
===========================================
+ Coverage    77.17%   77.42%   +0.25%     
===========================================
  Files          216      217       +1     
  Lines         5782     5802      +20     
  Branches      1240     1250      +10     
===========================================
+ Hits          4462     4492      +30     
+ Misses         786      780       -6     
+ Partials       534      530       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tillig tillig marked this pull request as ready for review March 12, 2026 20:35
@tillig tillig merged commit a6a8c62 into develop Mar 12, 2026
9 of 10 checks passed
@tillig tillig deleted the feature/perf branch March 12, 2026 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant