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

Enable deduplication of generics in Xamarin.iOS build #83193

Closed
4 tasks done
kotlarmilos opened this issue Mar 9, 2023 · 0 comments
Closed
4 tasks done

Enable deduplication of generics in Xamarin.iOS build #83193

kotlarmilos opened this issue Mar 9, 2023 · 0 comments
Assignees
Labels
area-Codegen-AOT-mono in-pr There is an active PR which will close this issue when it is merged
Milestone

Comments

@kotlarmilos
Copy link
Member

kotlarmilos commented Mar 9, 2023

Description

This issue tracks progress on updating the Xamarin.iOS build to support deduplication of generics in the native code during AOT compilation. When Mono AOT compiler encounters a generic instance that is not handled by generic sharing, it will emit a code for the instance. If the same instance is encountered during AOT compilation in multiple assemblies, the code will be emitted multiple times, increasing code size.

Tasks

  • Generate an empty assembly prior _AOTCompile target
  • Update Xamarin.iOS build to pass dedup-skip to AOT compiler
  • Update Xamarin.iOS build to pass the generated assembly along with other assemblies with dedup-include to AOT compiler
  • Test the update on MySingleView and MonoTouch tests

Related issues are #80419 and mono/mono#6965.

@kotlarmilos kotlarmilos added this to the 8.0.0 milestone Mar 9, 2023
@kotlarmilos kotlarmilos self-assigned this Mar 9, 2023
@kotlarmilos kotlarmilos added the in-pr There is an active PR which will close this issue when it is merged label Mar 30, 2023
rolfbjarne pushed a commit to xamarin/xamarin-macios that referenced this issue Mar 30, 2023
This PR contributes to dotnet/runtime#83193. It
creates a new target `_CreateAOTDedupAssembly`, and makes the `_AOTCompile`
depend on it. Also, it changes the `AOTCompile` task to pass `dedup-skip` and
`dedup-include` to the Mono AOT compiler.

The change was tested on `MySingleView` app and `Monotouch` tests. Both apps
are working, but some monotouch tests are failing due to
`Arg_NotlmplementedException`. Assumption is that calls between Obj-C and C#
could be problematic, as with the dedup improvement enabled, extra methods got
moved from origin assemblies to the dedup assembly, so native to managed
mapping could be corrupted.

Here are preliminary results comparing size on disk and build time between the
baseline (`net8.0` branch) and the target (this branch). Binlog details are
[attached](https://github.com/xamarin/xamarin-macios/files/10942772/binlog.zip).

| App                                      | Baseline size on disk .ipa (MB) | Target size on disk .ipa (MB) | Baseline size on disk .app (MB) | Target size on disk .app (MB) | Baseline build time (s) | Target build time (s) | .app diff (%) |
| ---------------------------------------- | ------------------------------- | ----------------------------- | ------------------------------- | ----------------------------- | ----------------------- | --------------------- | ------------- |
| MySingleView Release iOS                 | 5,40                            | 5,40                          | 29,2                            | 15,20                         | 29,18                   | 16,77                 | 47,94         |
| MySingleView Release  iOSSimulator-arm64 | N/A                             | N/A                           | 469,5                           | 341,80                        | 468,00                  | 330,00                | 27,20         |
| Monotouch Release llvm iOS               | 49,00                           | 38,80                         | 209,60                          | 157,40                        | 115,00                  | 130,00                | 24,90         |

Draft PR should get a full test run on the changes. The following tasks should
be resolved before making this PR ready for review.
@ghost ghost locked as resolved and limited conversation to collaborators Apr 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Codegen-AOT-mono in-pr There is an active PR which will close this issue when it is merged
Projects
None yet
Development

No branches or pull requests

1 participant