Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add design for lazy loading #1626

Merged
merged 5 commits into from
Jan 5, 2021
Merged

Conversation

sbomer
Copy link
Member

@sbomer sbomer commented Nov 12, 2020

This is a proposal for lazy loading to solve #1164 and related issues. This replaces the plan outlined in #1164 (comment), but there is some overlap because we still need to process references up-front for the copy action, if we want to preserve the current behavior.

I created a new branch for the feature that we can use to avoid breaking the constant propagation behavior in master.

docs/design/assembly-loading.md Outdated Show resolved Hide resolved
docs/design/assembly-loading.md Outdated Show resolved Hide resolved
docs/design/assembly-loading.md Outdated Show resolved Hide resolved
docs/design/assembly-loading.md Show resolved Hide resolved
docs/design/assembly-loading.md Outdated Show resolved Hide resolved
docs/design/assembly-loading.md Outdated Show resolved Hide resolved

### Exceptions to lazy loading

When the linker default action is `copy`, we will preserve the .NET5 behavior that keeps all statically referenced assemblies (that don't override the default action). For consistency with this behavior, static references of dynamically loaded assemblies will be kept as well. This will be done by pre-loading the reference closure of assemblies if the linker's default action is `copy`.
Copy link
Contributor

Choose a reason for hiding this comment

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

When the linker default action is copy

What does it mean? linker rarely runs in a single action mode

Copy link
Member Author

Choose a reason for hiding this comment

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

I meant -c/-u. I'm struggling a bit with how this should work. Maybe it would be ok to remove support for -c copy/-u copy instead, though we probably need to figure out #1269 before making that decision (there was a suggestion to use copy as the default action).

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we will always need to load all referenced assemblies, to support opting in to trimming via attributes. Even if we don't do it by passing -c copy -u copy, we want everything without an attribute to be kept - so we need to look at references. Maybe we can do it without reading the entire assembly, so that we still get some perf savings from lazy loading.

@sbomer sbomer closed this Dec 14, 2020
@sbomer sbomer deleted the branch dotnet:feature/lazyload December 14, 2020 22:54
@sbomer sbomer reopened this Jan 4, 2021
@sbomer sbomer changed the base branch from feature-lazyload to feature/lazyload January 4, 2021 22:52
docs/design/assembly-loading.md Outdated Show resolved Hide resolved
@sbomer sbomer merged commit 04c277c into dotnet:feature/lazyload Jan 5, 2021
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.

3 participants