Skip to content

Avoid func/capture allocations for non-lazy items #314

Merged
AArnott merged 9 commits into
microsoft:mainfrom
davkean:AvoidCapture
Mar 31, 2022
Merged

Avoid func/capture allocations for non-lazy items #314
AArnott merged 9 commits into
microsoft:mainfrom
davkean:AvoidCapture

Conversation

@davkean
Copy link
Copy Markdown
Member

@davkean davkean commented Mar 30, 2022

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:

image

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.

davkean added 7 commits March 30, 2022 16:15
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-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 30, 2022

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.10%. Comparing base (9f0d19b) to head (52f4bcd).
⚠️ Report is 2068 commits behind head on main.

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.
📢 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.

@AArnott AArnott requested review from AArnott and milopezc March 31, 2022 21:23
Copy link
Copy Markdown
Member

@AArnott AArnott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Yes, looking at it one commit at a time was a nice tip!

@davkean
Copy link
Copy Markdown
Member Author

davkean commented Mar 31, 2022

@AArnott Can you merge this? I don't have approval. Feel free to squash this under Avoid func/capture allocations for non-lazy items

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.

4 participants