fix: reduce O(types × inherited-members) registration cost from [ServiceKey] scan - #1495
Conversation
|
I've enabled the build to run and while I look over the code proper, it seems there are some formatting/style issues to fix to allow the build to progress. |
c4d5a06 to
7f0d04b
Compare
…iceKey] scan Co-authored-by: Brett Gabor <brett.gabor@tylertech.com>
Misfire there, looks like I forgot to run the linters before I pushed up. The latest push should have the correct styling. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1495 +/- ##
===========================================
- Coverage 78.33% 78.26% -0.07%
===========================================
Files 218 218
Lines 5944 5948 +4
Branches 1273 1274 +1
===========================================
- Hits 4656 4655 -1
- Misses 748 753 +5
Partials 540 540 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Thank you for this — outside PRs are a rarity for us and genuinely appreciated, and this is a good one. You found a real, non-obvious performance bug, diagnosed it correctly, and fixed it in the right place, with benchmarks and tests to back it up. That's the whole package. I reproduced the root cause and the improvement independently before reviewing, since a caching fix is the kind of thing worth confirming from scratch. Reflection hands back a distinct Measuring distinct derived types over a 20-property base (net10.0, Release):
Baseline growth is clearly super-linear (4.7x from 1000 to 2000); this PR is roughly linear. Matches the numbers in your PR description. Also verified:
Everything I've left in the inline comments is cosmetic — comment wording, one suppression written as The one item worth a real look is the comment on |
…m [ServiceKey] scan
|
Just addressed those changes via the fixup! commit. If everything looks good, I will go ahead and squash it back down! |
tillig
left a comment
There was a problem hiding this comment.
This is great! Thanks for your help and your patience. I'll see about getting a release out with this in it shortly.
As initially reported in #1480, a performance regression was discovered in the start time of Autofac applications with large numbers of derived types and inherited members. I was able to concretely nail this down using this example codebase where I was able to determine that the
ServiceKeyscan introduces aO(types × inherited-members)regression, that can be simplified down toO(distinct declared members).Here is the result of the benchmark run in that other repo (
./scripts/benchmark.sh 9.0.0 9.1.0 9.3.1 fix)Let me know if there is any additional information I can provide or change!