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 AOT] Improve build time on Apple mobile #110833

Open
kotlarmilos opened this issue Dec 19, 2024 · 0 comments
Open

[Mono AOT] Improve build time on Apple mobile #110833

kotlarmilos opened this issue Dec 19, 2024 · 0 comments
Assignees
Milestone

Comments

@kotlarmilos
Copy link
Member

Description

The build time for Apple mobile apps has significantly regressed in .NET 9: #110406.

Problem

Apple mobile apps use the Mono AOT llvm compiler. The Mono compiler generates specialized versions of generic methods for each value type, alongside the gsharedvt fallback. In .NET 9, increased use of generics and enabling of ISimdVector intrinsics in the BCL have led to a significant increase in the number of generated methods, causing the regression.

Additionally, the dedup optimization makes the problem worse. It collects all methods (around 200k) and emits them into a single assembly. This approach prevents parallel compilation and negatively impacts both JIT and code generation times.

Proposed solution

To improve the overall build time, we propose modifying how dedup assemblies are compiled by emitting dedup-ed methods directly in their source assemblies.

During assembly compilation, the AOT compiler can determine if a method can be dedup-ed and record this information in a hash table.

dedup_methods = g_hash_table_new (NULL, NULL);
dedup_methods_list = g_ptr_array_new ();

Collected methods can be included in source assemblies, enabling parallel compilation. Also, this should simplify the compilation process by avoiding the generation of artificial aot-instances.dll assembly.

Experiment

We want to validate potential impact of improvements before making changes by:

  • Measuring the build times of a MAUI template app with and without dedup optimization: Indicate the potential improvement from the proposed changes.
  • Collecting the number of generics and wrappers in .NET 8 and .NET 9: Quantify build time regression, regardless of dedup.
@kotlarmilos kotlarmilos added this to the 10.0.0 milestone Dec 19, 2024
@kotlarmilos kotlarmilos self-assigned this Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant