Reduce ExtensionManager memory allocations #12588
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TLDR; reduce test suite memory allocations by 40GB (> 90%).
I profiled tests run by OrchardCode suite to check if there's any easy wins to make them go faster. I was quite surprised by the memory allocation for the whole suite when run in Release mode, it was almost 44GB of memory allocated during the suite run.
After analysis I found out the
ExtensionManager
to be the culprit. It has a lot of closures and allocatey-LINQ usage + enumerators from interface use. Generally, I'd say it would be fine if done once but as it's repeated every time when system initializes in tests, it starts to cost.I went through the code and made it less cool by using concrete types, more imperative constructs instead of LINQ and better equality lookups (feature id instead of feature object).
The test suite now allocates 40GB less during run and the
ExtensionManager
should be the same functionality-wise. This helps with the test suite performance and probably also with OrchardCore cold startup speed at least.Relates to #12583
Before
After