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

[release/8.0-rc1] Annotate System.Linq.Expressions with RequiresDynamicCode #90616

Merged
merged 11 commits into from
Aug 16, 2023

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Aug 15, 2023

Backport of #90456 to release/8.0-rc1

/cc @agocke

Customer Impact

System.Linq.Expressions is a complicated area for Native AOT. Optimized compilation is not supported at all, but interpretation is. However, even with that, array creation and lifting of custom operators are not supported. This PR annotates array creation and disables custom operator lifting via a feature switch.

Notably, this does present a breaking change if you were relying on nullable lifting on custom operators in expression trees. There is no workaround in this situation. This feature is not supported in Native AOT.

Testing

Running existing unit tests and integration tests under Native AOT.

Risk

Low. This is an AOT-only change and mostly annotation-only.

agocke and others added 11 commits August 15, 2023 17:40
All this ended up with an RUC on Expression.Compile due to new arrays.
I could potentially silence this warning with a feature flag, but it is a
real risk, and one that users could maybe work around if alterted to the problem.
…ons/Expression.cs

Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>
Co-authored-by: Stephen Toub <stoub@microsoft.com>
@dotnet-issue-labeler
Copy link

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

@agocke agocke added the Servicing-consider Issue for next servicing release review label Aug 15, 2023
@ghost
Copy link

ghost commented Aug 15, 2023

Tagging subscribers to this area: @cston
See info in area-owners.md if you want to be subscribed.

Issue Details

Backport of #90456 to release/8.0-rc1

/cc @agocke

Customer Impact

Testing

Risk

IMPORTANT: If this backport is for a servicing release, please verify that:

  • The PR target branch is release/X.0-staging, not release/X.0.

  • If the change touches code that ships in a NuGet package, you have added the necessary package authoring and gotten it explicitly reviewed.

Author: github-actions[bot]
Assignees: -
Labels:

area-System.Linq.Expressions, new-api-needs-documentation

Milestone: -

@ivanpovazan
Copy link
Member

@agocke do these changes have any app size implications?
Additionally, can we run runtime-extra-platforms as well?

@agocke
Copy link
Member

agocke commented Aug 15, 2023

/azp run runtime-extra-platforms

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@agocke agocke added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Aug 15, 2023
@carlossanlop
Copy link
Member

The CI has failures. Is any of them related to this PR? If not, let me know so I can merge it (please don't click on "Update branch").

@agocke
Copy link
Member

agocke commented Aug 16, 2023

None of the failures seem related. I think this is good to merge.

@ivanpovazan This shouldn't have any material impact on size either way. It'll root Nullable<T> for the standard primitive types, but those were almost certainly rooted already.

@ivanpovazan
Copy link
Member

Thank you for verifying runtime-extra-platforms runs!

@ivanpovazan This shouldn't have any material impact on size either way. It'll root Nullable<T> for the standard primitive types, but those were almost certainly rooted already.

Just for the reference: I did a quick check with a sample iOS application referencing System.Linq.Expressions and the binary size slightly goes up by ~50Kb with this change, which is ~0,4% size regression.

@carlossanlop carlossanlop merged commit c79f02a into release/8.0-rc1 Aug 16, 2023
@carlossanlop carlossanlop deleted the backport/pr-90456-to-release/8.0-rc1 branch August 16, 2023 15:32
@eerhardt
Copy link
Member

Thanks for getting this into .NET 8, @agocke.

@agocke
Copy link
Member

agocke commented Aug 16, 2023

@ivanpovazan That still seems negligible, but slightly more than I expected. Did you happen to confirm that the only difference is the types I mentioned?

@ivanpovazan
Copy link
Member

@ivanpovazan That still seems negligible, but slightly more than I expected. Did you happen to confirm that the only difference is the types I mentioned?

I will try to do a diff with sizoscope and post it here, but probably tomorrow.

@ivanpovazan
Copy link
Member

ivanpovazan commented Aug 17, 2023

@agocke

  • Here is the detailed size comparison:
HelloiOS + TestLinqExpressions main PR diff (%) diff (Kb)
Binary size on disk 12731024 12781160 0,39% 50,14
  • Sizoscope diff (left - main, right - PR)

sle_cmp

@agocke
Copy link
Member

agocke commented Aug 17, 2023

Hmm, weird, the sizoscope difference shows 8 KB, which is closer to what I expected, instead of 50. @MichalStrehovsky might have some insight when he gets back

@ivanpovazan
Copy link
Member

ivanpovazan commented Aug 18, 2023

I repeated the measurements with a console app built on osx-arm64 and the difference is 16Kb. Still not sure about the extra 8Kb on Mac, but the extra bytes noticed on iOS seem to come from the fact that the bundler we internally use does not fully strip symbols from the iOS application (stripping only local symbols) - this is not the case with Xamarin builds, which properly strip all the symbols.

That being said, sorry for the false alarm regarding iOS size bump.

@agocke
Copy link
Member

agocke commented Aug 18, 2023

No problem -- thanks for the info. I thought I fixed the linker size issue, I may still need to look into it more.

@MichalStrehovsky
Copy link
Member

Hmm, weird, the sizoscope difference shows 8 KB, which is closer to what I expected, instead of 50. @MichalStrehovsky might have some insight when he gets back

Sizoscope/mstat doesn't capture everything in the executable but the size is usually proportional. You can get a closer view with IlcGenerateMapFile - the sizes of blobs that mstat cant account for might tell more.

@ghost ghost locked as resolved and limited conversation to collaborators Sep 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants