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

[mono] iOS - Size reduction: don't emit impossible generic function instantiations #54850

Closed
Tracked by #61815
imhameed opened this issue Jun 28, 2021 · 3 comments · Fixed by #70838
Closed
Tracked by #61815

[mono] iOS - Size reduction: don't emit impossible generic function instantiations #54850

imhameed opened this issue Jun 28, 2021 · 3 comments · Fixed by #70838
Assignees
Labels
area-Codegen-AOT-mono runtime-mono specific to the Mono runtime
Milestone

Comments

@imhameed
Copy link
Contributor

imhameed commented Jun 28, 2021

Seen while investigating size differences between legacy Mono and netcore Mono when used for iOS.

Some generic functions take generic parameters that themselves have type parameters that have struct constraints, but we still generate T_REF (boxed, non-value-type, shared) instantiations for these functions.

(This should affect any target that uses FullAOT; this includes iOS/tvOS)

@imhameed imhameed added area-Codegen-AOT-mono runtime-mono specific to the Mono runtime labels Jun 28, 2021
@imhameed imhameed added this to the 6.0.0 milestone Jun 28, 2021
@imhameed imhameed self-assigned this Jun 28, 2021
@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Jun 28, 2021
@imhameed imhameed removed the untriaged New issue has not been triaged by the area owner label Jun 28, 2021
@SamMonoRT SamMonoRT changed the title [mono] Size reduction: don't emit impossible generic function instantiations [mono] iOS - Size reduction: don't emit impossible generic function instantiations Jun 28, 2021
@imhameed
Copy link
Contributor Author

imhameed commented Jul 15, 2021

Tried a toy workaround for this that doesn't generate ref instantiations for functions with at least one struct constraint and doesn't generate gsharedvt instantiations for functions with at least one class constraint. This results in a savings of around 200 KiB in .text for a FullAOT + LLVM compiled copy of System.Private.CoreLib.dll on amd64 Linux (from 9.11 MiB to 8.92 MiB), and results in a __text savings of about 81.44 KiB for arm64 iOS using a linked copy of System.Private.CoreLib.dll (2.54 MiB to 2.46 MiB).

@imhameed imhameed modified the milestones: 6.0.0, 7.0.0 Jul 26, 2021
@imhameed
Copy link
Contributor Author

This should be straightforward, although it would be great to have better test FullAOT test coverage before doing this. #55362 goes part of the way there but it'd be preferable to have CI coverage that would have caught #56100.

@SamMonoRT
Copy link
Member

Assigning to @ivanpovazan

@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Jun 16, 2022
ivanpovazan added a commit that referenced this issue Jun 21, 2022
…rics in Mono AOT (#70838)

This change improves the AOTed code size by reducing the number of generated methods for generics.
Fixes #54850
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Jun 21, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Jul 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Codegen-AOT-mono runtime-mono specific to the Mono runtime
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants