Avoid func/capture allocations for non-lazy items #314
Merged
Conversation
Non-lazy imports were paying for capture and func creation, despite the func immediately being invoked immediately after it was created. Instead take a different path for the lazy versus non-lazy case so that only Lazy<T> exports pay for it. This was allocating about 100 MB opening and closing Orchard Core, but the end result will depend on how many lazy versus non-lazy items are in the composition graph.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #314 +/- ##
==========================================
- Coverage 76.15% 76.10% -0.05%
==========================================
Files 110 110
Lines 7187 7174 -13
==========================================
- Hits 5473 5460 -13
Misses 1714 1714 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
AArnott
approved these changes
Mar 31, 2022
Member
AArnott
left a comment
There was a problem hiding this comment.
Looks good to me. Yes, looking at it one commit at a time was a nice tip!
Member
Author
|
@AArnott Can you merge this? I don't have approval. Feel free to squash this under Avoid func/capture allocations for non-lazy items |
milopezc
approved these changes
Mar 31, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Non-lazy imports were paying for capture and Func creation, despite the Func being invoked immediately after it was created. Instead take a different path for the lazy versus non-lazy case so that only Lazy exports pays for the allocations.
This was allocating about 100 MB opening and closing Orchard Core, but the end result will depend on how many lazy versus non-lazy items are in the composition graph:
This one was a bit tricky to approach to avoid leaking "this" and to handle export provider import and I took a few different paths, and ended up with this one. This one is much easier to read commit by commit.