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

MAUI iOS sample app size regression compared to .NET7 #79825

Closed
ivanpovazan opened this issue Dec 19, 2022 · 8 comments
Closed

MAUI iOS sample app size regression compared to .NET7 #79825

ivanpovazan opened this issue Dec 19, 2022 · 8 comments
Assignees
Labels
area-Codegen-AOT-mono size-reduction Issues impacting final app size primary for size sensitive workloads
Milestone

Comments

@ivanpovazan
Copy link
Member

Size regression for MAUI iOS apps

MAUI sample app dotnet new maui -n "MyMauiApp" has regressed in size compared to the .NET7 release:

  • Unzipped archive: .app directory size regressed around 78.5% from 40598192 to 72477624 bytes
  • Application archive: .ipa file size regressed around 74% from 13074853 to 22755931 bytes

when compared against dotnet/runtime main branch at: a92c5bc

Linked issues

Similar size regressions have been reported for the Mono sample app and WASM here:

for which the following issues have been detected as the ones causing the regressions:

Repro steps

  1. Check out dotnet/runtime repository into a local dir (<some_repo_dir> will be used as a placeholder further):
git clone https://github.com/dotnet/runtime.git <some_repo_dir>
  1. Build dotnet/runtime for iOS:
cd <some_repo_dir>
./build.sh mono+libs -c Release -os iOS -arch arm64
  1. Download and install dotnet 7.0.100 from https://dotnet.microsoft.com/en-us/download/dotnet/7.0
  2. Make sure 7.0.100 is the one on the path
cd ~/
dotnet --version
7.0.100
  1. Install maui workload
sudo dotnet workload install maui --source https://api.nuget.org/v3/index.json
  1. Create a sample MAUI app
dotnet new maui -n "MyMauiApp"
cd MyMauiApp
  1. Adjust the app project by adding the following Target in MyMauiApp.csproj file:
<Target Name="UpdateRuntimePackAndAOTCompiler" 
	AfterTargets="ResolveFrameworkReferences"
	Condition="'$(UseCurrentMainBranch)' == 'true'" >
	<Error Condition="'$(DotnetRuntimeRepo)' == ''" Text="You must specify the location of your dotnet/runtime repository via -p:DotnetRuntimeRepo=&lt;some_repo_dir&gt;"/>
	<ItemGroup>
		<!-- update runtime pack to local build -->
		<ResolvedRuntimePack PackageDirectory="$(DotnetRuntimeRepo)/artifacts/bin/microsoft.netcore.app.runtime.ios-arm64/Release"
			Condition="'%(ResolvedRuntimePack.FrameworkName)' == 'Microsoft.NETCore.App'" />
		<!-- remove AOT compiler reference for ios-arm64 -->
		<MonoAotCrossCompiler Remove="@(MonoAotCrossCompiler)"
			Condition="%(RuntimeIdentifier) == 'ios-arm64'" />
		<!-- update AOT compiler reference to local build -->
		<MonoAotCrossCompiler Include="$(DotnetRuntimeRepo)/artifacts/bin/mono/iOS.arm64.Release/cross/ios-arm64/mono-aot-cross">
			<RuntimeIdentifier>ios-arm64</RuntimeIdentifier>
		</MonoAotCrossCompiler>
	</ItemGroup>
</Target>
  1. Build the project to get sizes for .NET7 release:
dotnet publish -c Release -f net7.0-ios -r ios-arm64 --self-contained -bl -p:_RequireCodeSigning=false
  1. Inspect .ipa file and .app folder sizes:
ls -al bin/Release/net7.0-ios/ios-arm64/publish/MyMauiApp.ipa
ls -al bin/Release/net7.0-ios/ios-arm64/MyMauiApp.app
  1. Now build the project against the locally built runtime - current main from step (2) by:
  • passing the project property DotnetRuntimeRepo with the path to your local dotnet/runtime directory (instead of the <some_repo_dir> placeholder)
  • passing the project property UseCurrentMainBranch with the value true

in the following way:

rm -rf bin obj
dotnet publish -c Release -f net7.0-ios -r ios-arm64 --self-contained -bl -p:_RequireCodeSigning=false -p:DotnetRuntimeRepo="<some_repo_dir>" -p:UseCurrentMainBranch=true
  1. Repeat inspection of the file/folder sizes from step (9)

Size on disk comparison (in bytes)

# File name Size net7 release (b) Size current main (b) Diff (%)
1 AboutAssets.txt 656 656 0,00%
2 Assets.car 50424 50424 0,00%
3 Info.plist 1424 1424 0,00%
4 MauiSplash.storyboardc 160 160 0,00%
5 Microsoft.Extensions.Configuration.Abstractions.aotdata.arm64 920 920 0,00%
6 Microsoft.Extensions.Configuration.Abstractions.dll 5632 5632 0,00%
7 Microsoft.Extensions.Configuration.aotdata.arm64 53928 179512 232,87%
8 Microsoft.Extensions.Configuration.dll 9728 9728 0,00%
9 Microsoft.Extensions.DependencyInjection.Abstractions.aotdata.arm64 7448 178512 2296,78%
10 Microsoft.Extensions.DependencyInjection.Abstractions.dll 13312 13312 0,00%
11 Microsoft.Extensions.DependencyInjection.aotdata.arm64 123976 253960 104,85%
12 Microsoft.Extensions.DependencyInjection.dll 25600 25600 0,00%
13 Microsoft.Extensions.Logging.Abstractions.aotdata.arm64 44640 184584 313,49%
14 Microsoft.Extensions.Logging.Abstractions.dll 12800 12800 0,00%
15 Microsoft.Extensions.Logging.aotdata.arm64 60832 188192 209,36%
16 Microsoft.Extensions.Logging.dll 13312 13312 0,00%
17 Microsoft.Extensions.Options.aotdata.arm64 10840 10832 -0,07%
18 Microsoft.Extensions.Options.dll 12288 12288 0,00%
19 Microsoft.Extensions.Primitives.aotdata.arm64 3936 3920 -0,41%
20 Microsoft.Extensions.Primitives.dll 7168 7168 0,00%
21 Microsoft.Maui.Controls.Xaml.aotdata.arm64 97120 243424 150,64%
22 Microsoft.Maui.Controls.Xaml.dll 74240 74240 0,00%
23 Microsoft.Maui.Controls.aotdata.arm64 914264 1056064 15,51%
24 Microsoft.Maui.Controls.dll 1038336 1038336 0,00%
25 Microsoft.Maui.Essentials.aotdata.arm64 62792 197168 214,00%
26 Microsoft.Maui.Essentials.dll 30720 30720 0,00%
27 Microsoft.Maui.Graphics.aotdata.arm64 142944 308936 116,12%
28 Microsoft.Maui.Graphics.dll 114688 114688 0,00%
29 Microsoft.Maui.aotdata.arm64 384816 534872 38,99%
30 Microsoft.Maui.dll 386048 386048 0,00%
31 Microsoft.iOS.aotdata.arm64 325264 461264 41,81%
32 Microsoft.iOS.dll 497664 497664 0,00%
33 MyMauiApp 29000688 56731120 95,62%
34 MyMauiApp.aotdata.arm64 9464 181840 1821,39%
35 MyMauiApp.dll 18432 18432 0,00%
36 OpenSans-Regular.ttf 107184 107184 0,00%
37 OpenSans-Semibold.ttf 111068 111068 0,00%
38 PkgInfo 8 8 0,00%
39 System.Collections.Concurrent.aotdata.arm64 74544 207520 178,39%
40 System.Collections.Concurrent.dll 13312 13312 0,00%
41 System.Collections.NonGeneric.aotdata.arm64 1312 1312 0,00%
42 System.Collections.NonGeneric.dll 7168 7168 0,00%
43 System.Collections.Specialized.aotdata.arm64 1392 1584 13,79%
44 System.Collections.Specialized.dll 8192 8192 0,00%
45 System.Collections.aotdata.arm64 6952 7208 3,68%
46 System.Collections.dll 8192 8192 0,00%
47 System.ComponentModel.Primitives.aotdata.arm64 2096 178344 8408,78%
48 System.ComponentModel.Primitives.dll 9216 9216 0,00%
49 System.ComponentModel.TypeConverter.aotdata.arm64 16544 192896 1065,96%
50 System.ComponentModel.TypeConverter.dll 49664 49664 0,00%
51 System.ComponentModel.aotdata.arm64 856 856 0,00%
52 System.ComponentModel.dll 4608 4608 0,00%
53 System.Console.aotdata.arm64 46432 195856 321,81%
54 System.Console.dll 8704 8704 0,00%
55 System.Diagnostics.TraceSource.aotdata.arm64 2416 2416 0,00%
56 System.Diagnostics.TraceSource.dll 8704 8704 0,00%
57 System.Drawing.Primitives.aotdata.arm64 4856 175960 3523,56%
58 System.Drawing.Primitives.dll 7168 7168 0,00%
59 System.Drawing.aotdata.arm64 808 808 0,00%
60 System.Drawing.dll 4608 4608 0,00%
61 System.Linq.Expressions.aotdata.arm64 499248 610776 22,34%
62 System.Linq.Expressions.dll 120320 120320 0,00%
63 System.Linq.aotdata.arm64 121560 275264 126,44%
64 System.Linq.dll 22528 22016 -2,27%
65 System.Memory.aotdata.arm64 824 824 0,00%
66 System.Memory.dll 4608 4096 -11,11%
67 System.Net.Http.aotdata.arm64 130696 311760 138,54%
68 System.Net.Http.dll 61440 61952 0,83%
69 System.Net.Primitives.aotdata.arm64 1424 1432 0,56%
70 System.Net.Primitives.dll 8704 8704 0,00%
71 System.Net.Requests.aotdata.arm64 928 928 0,00%
72 System.Net.Requests.dll 5632 5632 0,00%
73 System.Net.Security.aotdata.arm64 888 888 0,00%
74 System.Net.Security.dll 4608 5120 11,11%
75 System.Net.ServicePoint.aotdata.arm64 1960 1960 0,00%
76 System.Net.ServicePoint.dll 5632 5632 0,00%
77 System.Numerics.Vectors.aotdata.arm64 816 816 0,00%
78 System.Numerics.Vectors.dll 4608 4608 0,00%
79 System.ObjectModel.aotdata.arm64 10304 11112 7,84%
80 System.ObjectModel.dll 13312 13312 0,00%
81 System.Private.CoreLib.aotdata.arm64 1318848 1777432 34,77%
82 System.Private.CoreLib.dll 912384 934400 2,41%
83 System.Private.Uri.aotdata.arm64 81728 275344 236,90%
84 System.Private.Uri.dll 25600 26624 4,00%
85 System.Private.Xml.aotdata.arm64 229216 376784 64,38%
86 System.Private.Xml.dll 247296 248320 0,41%
87 System.Runtime.InteropServices.aotdata.arm64 840 840 0,00%
88 System.Runtime.InteropServices.dll 4608 4608 0,00%
89 System.Runtime.aotdata.arm64 808 808 0,00%
90 System.Runtime.dll 11776 11776 0,00%
91 System.Security.Cryptography.aotdata.arm64 43000 180640 320,09%
92 System.Security.Cryptography.dll 5632 5632 0,00%
93 System.Text.RegularExpressions.aotdata.arm64 520208 677736 30,28%
94 System.Text.RegularExpressions.dll 139264 139776 0,37%
95 System.Threading.Thread.aotdata.arm64 816 816 0,00%
96 System.Threading.Thread.dll 4096 4608 12,50%
97 System.Threading.aotdata.arm64 824 824 0,00%
98 System.Threading.dll 4608 4608 0,00%
99 System.Xml.ReaderWriter.aotdata.arm64 816 816 0,00%
100 System.Xml.ReaderWriter.dll 4608 4608 0,00%
101 System.aotdata.arm64 800 800 0,00%
102 System.dll 4096 4096 0,00%
103 _CodeSignature 96 96 0,00%
104 [email protected] 1361 1361 0,00%
105 appicon76x76@2x~ipad.png 1649 1649 0,00%
106 dotnet_bot.png 19036 19036 0,00%
107 [email protected] 41155 41155 0,00%
108 [email protected] 55868 55868 0,00%
109 icudt.dat 1824544 1859040 1,89%
110 runtimeconfig.bin 983 983 0,00%
111 splash.png 1554 1554 0,00%
112 [email protected] 2750 2750 0,00%
113 [email protected] 4776 4776 0,00%
TOTAL: 40598192 72477624 78,52%

Observation

Biggest differences can be seen in the app binary MyMauiApp (row 33) and .aotdata.arm64 files.


/cc: @SamMonoRT @kotlarmilos @rolfbjarne @jonathanpeppers @vargaz @stephentoub

@ivanpovazan ivanpovazan added area-Codegen-AOT-mono size-reduction Issues impacting final app size primary for size sensitive workloads labels Dec 19, 2022
@ivanpovazan ivanpovazan added this to the Future milestone Dec 19, 2022
@ghost
Copy link

ghost commented Dec 19, 2022

Tagging subscribers to 'size-reduction': @eerhardt, @SamMonoRT, @marek-safar
See info in area-owners.md if you want to be subscribed.

Issue Details

Size regression for MAUI iOS apps

MAUI sample app dotnet new maui -n "MyMauiApp" has regressed in size compared to the .NET7 release:

  • Unzipped archive: .app directory size regressed around 78.5% from 40598192 to 72477624 bytes
  • Application archive: .ipa file size regressed around 74% from 13074853 to 22755931 bytes

when compared against dotnet/runtime main branch at: a92c5bc

Linked issues

Similar size regressions have been reported for the Mono sample app and WASM here:

for which the following issues have been detected as the ones causing the regressions:

Repro steps

  1. Check out dotnet/runtime repository into a local dir (<some_repo_dir> will be used as a placeholder further):
git clone https://github.com/dotnet/runtime.git <some_repo_dir>
  1. Build dotnet/runtime for iOS:
cd <some_repo_dir>
./build.sh mono+libs -c Release -os iOS -arch arm64
  1. Download and install dotnet 7.0.100 from https://dotnet.microsoft.com/en-us/download/dotnet/7.0
  2. Make sure 7.0.100 is the one on the path
cd ~/
dotnet --version
7.0.100
  1. Install maui workload
sudo dotnet workload install maui --source https://api.nuget.org/v3/index.json
  1. Create a sample MAUI app
dotnet new maui -n "MyMauiApp"
cd MyMauiApp
  1. Adjust the app project by adding the following Target in MyMauiApp.csproj file:
<Target Name="UpdateRuntimePackAndAOTCompiler" 
	AfterTargets="ResolveFrameworkReferences"
	Condition="'$(UseCurrentMainBranch)' == 'true'" >
	<Error Condition="'$(DotnetRuntimeRepo)' == ''" Text="You must specify the location of your dotnet/runtime repository via -p:DotnetRuntimeRepo=&lt;some_repo_dir&gt;"/>
	<ItemGroup>
		<!-- update runtime pack to local build -->
		<ResolvedRuntimePack PackageDirectory="$(DotnetRuntimeRepo)/artifacts/bin/microsoft.netcore.app.runtime.ios-arm64/Release"
			Condition="'%(ResolvedRuntimePack.FrameworkName)' == 'Microsoft.NETCore.App'" />
		<!-- remove AOT compiler reference for ios-arm64 -->
		<MonoAotCrossCompiler Remove="@(MonoAotCrossCompiler)"
			Condition="%(RuntimeIdentifier) == 'ios-arm64'" />
		<!-- update AOT compiler reference to local build -->
		<MonoAotCrossCompiler Include="$(DotnetRuntimeRepo)/artifacts/bin/mono/iOS.arm64.Release/cross/ios-arm64/mono-aot-cross">
			<RuntimeIdentifier>ios-arm64</RuntimeIdentifier>
		</MonoAotCrossCompiler>
	</ItemGroup>
</Target>
  1. Build the project to get sizes for .NET7 release:
dotnet publish -c Release -f net7.0-ios -r ios-arm64 --self-contained -bl -p:_RequireCodeSigning=false
  1. Inspect .ipa file and .app folder sizes:
ls -al bin/Release/net7.0-ios/ios-arm64/publish/MyMauiApp.ipa
ls -al bin/Release/net7.0-ios/ios-arm64/MyMauiApp.app
  1. Now build the project against the locally built runtime - current main from step (2) by:
  • passing the project property DotnetRuntimeRepo with the path to your local dotnet/runtime directory (instead of the <some_repo_dir> placeholder)
  • passing the project property UseCurrentMainBranch with the value true

in the following way:

rm -rf bin obj
dotnet publish -c Release -f net7.0-ios -r ios-arm64 --self-contained -bl -p:_RequireCodeSigning=false -p:DotnetRuntimeRepo="<some_repo_dir>" -p:UseCurrentMainBranch=true
  1. Repeat inspection of the file/folder sizes from step (9)

Size on disk comparison (in bytes)

# File name Size net7 release (b) Size current main (b) Diff (%)
1 AboutAssets.txt 656 656 0,00%
2 Assets.car 50424 50424 0,00%
3 Info.plist 1424 1424 0,00%
4 MauiSplash.storyboardc 160 160 0,00%
5 Microsoft.Extensions.Configuration.Abstractions.aotdata.arm64 920 920 0,00%
6 Microsoft.Extensions.Configuration.Abstractions.dll 5632 5632 0,00%
7 Microsoft.Extensions.Configuration.aotdata.arm64 53928 179512 232,87%
8 Microsoft.Extensions.Configuration.dll 9728 9728 0,00%
9 Microsoft.Extensions.DependencyInjection.Abstractions.aotdata.arm64 7448 178512 2296,78%
10 Microsoft.Extensions.DependencyInjection.Abstractions.dll 13312 13312 0,00%
11 Microsoft.Extensions.DependencyInjection.aotdata.arm64 123976 253960 104,85%
12 Microsoft.Extensions.DependencyInjection.dll 25600 25600 0,00%
13 Microsoft.Extensions.Logging.Abstractions.aotdata.arm64 44640 184584 313,49%
14 Microsoft.Extensions.Logging.Abstractions.dll 12800 12800 0,00%
15 Microsoft.Extensions.Logging.aotdata.arm64 60832 188192 209,36%
16 Microsoft.Extensions.Logging.dll 13312 13312 0,00%
17 Microsoft.Extensions.Options.aotdata.arm64 10840 10832 -0,07%
18 Microsoft.Extensions.Options.dll 12288 12288 0,00%
19 Microsoft.Extensions.Primitives.aotdata.arm64 3936 3920 -0,41%
20 Microsoft.Extensions.Primitives.dll 7168 7168 0,00%
21 Microsoft.Maui.Controls.Xaml.aotdata.arm64 97120 243424 150,64%
22 Microsoft.Maui.Controls.Xaml.dll 74240 74240 0,00%
23 Microsoft.Maui.Controls.aotdata.arm64 914264 1056064 15,51%
24 Microsoft.Maui.Controls.dll 1038336 1038336 0,00%
25 Microsoft.Maui.Essentials.aotdata.arm64 62792 197168 214,00%
26 Microsoft.Maui.Essentials.dll 30720 30720 0,00%
27 Microsoft.Maui.Graphics.aotdata.arm64 142944 308936 116,12%
28 Microsoft.Maui.Graphics.dll 114688 114688 0,00%
29 Microsoft.Maui.aotdata.arm64 384816 534872 38,99%
30 Microsoft.Maui.dll 386048 386048 0,00%
31 Microsoft.iOS.aotdata.arm64 325264 461264 41,81%
32 Microsoft.iOS.dll 497664 497664 0,00%
33 MyMauiApp 29000688 56731120 95,62%
34 MyMauiApp.aotdata.arm64 9464 181840 1821,39%
35 MyMauiApp.dll 18432 18432 0,00%
36 OpenSans-Regular.ttf 107184 107184 0,00%
37 OpenSans-Semibold.ttf 111068 111068 0,00%
38 PkgInfo 8 8 0,00%
39 System.Collections.Concurrent.aotdata.arm64 74544 207520 178,39%
40 System.Collections.Concurrent.dll 13312 13312 0,00%
41 System.Collections.NonGeneric.aotdata.arm64 1312 1312 0,00%
42 System.Collections.NonGeneric.dll 7168 7168 0,00%
43 System.Collections.Specialized.aotdata.arm64 1392 1584 13,79%
44 System.Collections.Specialized.dll 8192 8192 0,00%
45 System.Collections.aotdata.arm64 6952 7208 3,68%
46 System.Collections.dll 8192 8192 0,00%
47 System.ComponentModel.Primitives.aotdata.arm64 2096 178344 8408,78%
48 System.ComponentModel.Primitives.dll 9216 9216 0,00%
49 System.ComponentModel.TypeConverter.aotdata.arm64 16544 192896 1065,96%
50 System.ComponentModel.TypeConverter.dll 49664 49664 0,00%
51 System.ComponentModel.aotdata.arm64 856 856 0,00%
52 System.ComponentModel.dll 4608 4608 0,00%
53 System.Console.aotdata.arm64 46432 195856 321,81%
54 System.Console.dll 8704 8704 0,00%
55 System.Diagnostics.TraceSource.aotdata.arm64 2416 2416 0,00%
56 System.Diagnostics.TraceSource.dll 8704 8704 0,00%
57 System.Drawing.Primitives.aotdata.arm64 4856 175960 3523,56%
58 System.Drawing.Primitives.dll 7168 7168 0,00%
59 System.Drawing.aotdata.arm64 808 808 0,00%
60 System.Drawing.dll 4608 4608 0,00%
61 System.Linq.Expressions.aotdata.arm64 499248 610776 22,34%
62 System.Linq.Expressions.dll 120320 120320 0,00%
63 System.Linq.aotdata.arm64 121560 275264 126,44%
64 System.Linq.dll 22528 22016 -2,27%
65 System.Memory.aotdata.arm64 824 824 0,00%
66 System.Memory.dll 4608 4096 -11,11%
67 System.Net.Http.aotdata.arm64 130696 311760 138,54%
68 System.Net.Http.dll 61440 61952 0,83%
69 System.Net.Primitives.aotdata.arm64 1424 1432 0,56%
70 System.Net.Primitives.dll 8704 8704 0,00%
71 System.Net.Requests.aotdata.arm64 928 928 0,00%
72 System.Net.Requests.dll 5632 5632 0,00%
73 System.Net.Security.aotdata.arm64 888 888 0,00%
74 System.Net.Security.dll 4608 5120 11,11%
75 System.Net.ServicePoint.aotdata.arm64 1960 1960 0,00%
76 System.Net.ServicePoint.dll 5632 5632 0,00%
77 System.Numerics.Vectors.aotdata.arm64 816 816 0,00%
78 System.Numerics.Vectors.dll 4608 4608 0,00%
79 System.ObjectModel.aotdata.arm64 10304 11112 7,84%
80 System.ObjectModel.dll 13312 13312 0,00%
81 System.Private.CoreLib.aotdata.arm64 1318848 1777432 34,77%
82 System.Private.CoreLib.dll 912384 934400 2,41%
83 System.Private.Uri.aotdata.arm64 81728 275344 236,90%
84 System.Private.Uri.dll 25600 26624 4,00%
85 System.Private.Xml.aotdata.arm64 229216 376784 64,38%
86 System.Private.Xml.dll 247296 248320 0,41%
87 System.Runtime.InteropServices.aotdata.arm64 840 840 0,00%
88 System.Runtime.InteropServices.dll 4608 4608 0,00%
89 System.Runtime.aotdata.arm64 808 808 0,00%
90 System.Runtime.dll 11776 11776 0,00%
91 System.Security.Cryptography.aotdata.arm64 43000 180640 320,09%
92 System.Security.Cryptography.dll 5632 5632 0,00%
93 System.Text.RegularExpressions.aotdata.arm64 520208 677736 30,28%
94 System.Text.RegularExpressions.dll 139264 139776 0,37%
95 System.Threading.Thread.aotdata.arm64 816 816 0,00%
96 System.Threading.Thread.dll 4096 4608 12,50%
97 System.Threading.aotdata.arm64 824 824 0,00%
98 System.Threading.dll 4608 4608 0,00%
99 System.Xml.ReaderWriter.aotdata.arm64 816 816 0,00%
100 System.Xml.ReaderWriter.dll 4608 4608 0,00%
101 System.aotdata.arm64 800 800 0,00%
102 System.dll 4096 4096 0,00%
103 _CodeSignature 96 96 0,00%
104 [email protected] 1361 1361 0,00%
105 appicon76x76@2x~ipad.png 1649 1649 0,00%
106 dotnet_bot.png 19036 19036 0,00%
107 [email protected] 41155 41155 0,00%
108 [email protected] 55868 55868 0,00%
109 icudt.dat 1824544 1859040 1,89%
110 runtimeconfig.bin 983 983 0,00%
111 splash.png 1554 1554 0,00%
112 [email protected] 2750 2750 0,00%
113 [email protected] 4776 4776 0,00%
TOTAL: 40598192 72477624 78,52%

Observation

Biggest differences can be seen in the app binary MyMauiApp (row 33) and .aotdata.arm64 files.


/cc: @SamMonoRT @kotlarmilos @rolfbjarne @jonathanpeppers @vargaz @stephentoub

Author: ivanpovazan
Assignees: -
Labels:

area-Codegen-AOT-mono, size-reduction

Milestone: Future

@vargaz
Copy link
Contributor

vargaz commented Dec 19, 2022

A size increase this large might be caused by generating/not stripping debug info etc.

@vargaz
Copy link
Contributor

vargaz commented Dec 19, 2022

Some observations:

  • the corlib .o file is 18mb vs 8mb previously.
  • about 3b of that seems to be Vector methods/shared methods/instances
  • the linked corlib is still 1.6mb and contains 13k methods

As discussed elsewhere, adding a linker conditional to the Vector fallback methods which links them out if the platform supports SIMD would probably help a lot.

@ivanpovazan
Copy link
Member Author

ivanpovazan commented Dec 19, 2022

Here is another comparison table with the data just before the enums change i.e. its parent commit: 6e0c046 and with the change included 62f3eb2.
It can be seen that regression progressed: 32,74% -> 63,68% -> 78,52% reaching the current state.

Unfortunately I have troubles building the sample app with the earlier changes regarding generics 486682a but will update the issue if I managed to get around the compilation failures, to see how much this change affected the first regression point of 32,74%

Size on disk comparison (in bytes)

# File name Size net7 release Size with 6e0c046 Diff-to-net7 Size with 62f3eb2 Diff-to-net7 Size current main Diff-to-net7
1 AboutAssets.txt 656 656 0,00% 656 0,00% 656 0,00%
2 Assets.car 50424 50424 0,00% 50424 0,00% 50424 0,00%
3 Info.plist 1424 1424 0,00% 1424 0,00% 1424 0,00%
4 MauiSplash.storyboardc 160 160 0,00% 160 0,00% 160 0,00%
5 Microsoft.Extensions.Configuration.Abstractions.aotdata.arm64 920 920 0,00% 920 0,00% 920 0,00%
6 Microsoft.Extensions.Configuration.Abstractions.dll 5632 5632 0,00% 5632 0,00% 5632 0,00%
7 Microsoft.Extensions.Configuration.aotdata.arm64 53928 90344 67,53% 149368 176,98% 179512 232,87%
8 Microsoft.Extensions.Configuration.dll 9728 9728 0,00% 9728 0,00% 9728 0,00%
9 Microsoft.Extensions.DependencyInjection.Abstractions.aotdata.arm64 7448 7496 0,64% 148984 1900,32% 178512 2296,78%
10 Microsoft.Extensions.DependencyInjection.Abstractions.dll 13312 13312 0,00% 13312 0,00% 13312 0,00%
11 Microsoft.Extensions.DependencyInjection.aotdata.arm64 123976 193400 56,00% 243296 96,24% 253960 104,85%
12 Microsoft.Extensions.DependencyInjection.dll 25600 25600 0,00% 25600 0,00% 25600 0,00%
13 Microsoft.Extensions.Logging.Abstractions.aotdata.arm64 44640 72160 61,65% 153408 243,66% 184584 313,49%
14 Microsoft.Extensions.Logging.Abstractions.dll 12800 12800 0,00% 12800 0,00% 12800 0,00%
15 Microsoft.Extensions.Logging.aotdata.arm64 60832 97304 59,96% 158464 160,49% 188192 209,36%
16 Microsoft.Extensions.Logging.dll 13312 13312 0,00% 13312 0,00% 13312 0,00%
17 Microsoft.Extensions.Options.aotdata.arm64 10840 10832 -0,07% 10832 -0,07% 10832 -0,07%
18 Microsoft.Extensions.Options.dll 12288 12288 0,00% 12288 0,00% 12288 0,00%
19 Microsoft.Extensions.Primitives.aotdata.arm64 3936 3920 -0,41% 3920 -0,41% 3920 -0,41%
20 Microsoft.Extensions.Primitives.dll 7168 7168 0,00% 7168 0,00% 7168 0,00%
21 Microsoft.Maui.Controls.Xaml.aotdata.arm64 97120 130176 34,04% 192776 98,49% 243424 150,64%
22 Microsoft.Maui.Controls.Xaml.dll 74240 74240 0,00% 74240 0,00% 74240 0,00%
23 Microsoft.Maui.Controls.aotdata.arm64 914264 943536 3,20% 1020440 11,61% 1056064 15,51%
24 Microsoft.Maui.Controls.dll 1038336 1038336 0,00% 1038336 0,00% 1038336 0,00%
25 Microsoft.Maui.Essentials.aotdata.arm64 62792 87352 39,11% 166848 165,72% 197168 214,00%
26 Microsoft.Maui.Essentials.dll 30720 30720 0,00% 30720 0,00% 30720 0,00%
27 Microsoft.Maui.Graphics.aotdata.arm64 142944 181296 26,83% 269400 88,47% 308936 116,12%
28 Microsoft.Maui.Graphics.dll 114688 114688 0,00% 114688 0,00% 114688 0,00%
29 Microsoft.Maui.aotdata.arm64 384816 452776 17,66% 525880 36,66% 534872 38,99%
30 Microsoft.Maui.dll 386048 386048 0,00% 386048 0,00% 386048 0,00%
31 Microsoft.iOS.aotdata.arm64 325264 353152 8,57% 429296 31,98% 461264 41,81%
32 Microsoft.iOS.dll 497664 497664 0,00% 497664 0,00% 497664 0,00%
33 MyMauiApp 29000688 41014544 41,43% 51805456 78,64% 56731120 95,62%
34 MyMauiApp.aotdata.arm64 9464 9544 0,85% 151944 1505,49% 181840 1821,39%
35 MyMauiApp.dll 18432 18432 0,00% 18432 0,00% 18432 0,00%
36 OpenSans-Regular.ttf 107184 107184 0,00% 107184 0,00% 107184 0,00%
37 OpenSans-Semibold.ttf 111068 111068 0,00% 111068 0,00% 111068 0,00%
38 PkgInfo 8 8 0,00% 8 0,00% 8 0,00%
39 System.Collections.Concurrent.aotdata.arm64 74544 125256 68,03% 213176 185,97% 207520 178,39%
40 System.Collections.Concurrent.dll 13312 13312 0,00% 13312 0,00% 13312 0,00%
41 System.Collections.NonGeneric.aotdata.arm64 1312 1312 0,00% 1312 0,00% 1312 0,00%
42 System.Collections.NonGeneric.dll 7168 7168 0,00% 7168 0,00% 7168 0,00%
43 System.Collections.Specialized.aotdata.arm64 1392 1392 0,00% 1392 0,00% 1584 13,79%
44 System.Collections.Specialized.dll 8192 8192 0,00% 8192 0,00% 8192 0,00%
45 System.Collections.aotdata.arm64 6952 6952 0,00% 6952 0,00% 7208 3,68%
46 System.Collections.dll 8192 8192 0,00% 8192 0,00% 8192 0,00%
47 System.ComponentModel.Primitives.aotdata.arm64 2096 2096 0,00% 2096 0,00% 178344 8408,78%
48 System.ComponentModel.Primitives.dll 9216 9216 0,00% 9216 0,00% 9216 0,00%
49 System.ComponentModel.TypeConverter.aotdata.arm64 16544 16544 0,00% 16544 0,00% 192896 1065,96%
50 System.ComponentModel.TypeConverter.dll 49664 49664 0,00% 49664 0,00% 49664 0,00%
51 System.ComponentModel.aotdata.arm64 856 856 0,00% 856 0,00% 856 0,00%
52 System.ComponentModel.dll 4608 4608 0,00% 4608 0,00% 4608 0,00%
53 System.Console.aotdata.arm64 46432 73920 59,20% 152792 229,07% 195856 321,81%
54 System.Console.dll 8704 8704 0,00% 8704 0,00% 8704 0,00%
55 System.Diagnostics.TraceSource.aotdata.arm64 2416 2416 0,00% 2416 0,00% 2416 0,00%
56 System.Diagnostics.TraceSource.dll 8704 8704 0,00% 8704 0,00% 8704 0,00%
57 System.Drawing.Primitives.aotdata.arm64 4856 4928 1,48% 146400 2914,83% 175960 3523,56%
58 System.Drawing.Primitives.dll 7168 7168 0,00% 7168 0,00% 7168 0,00%
59 System.Drawing.aotdata.arm64 808 808 0,00% 808 0,00% 808 0,00%
60 System.Drawing.dll 4608 4608 0,00% 4608 0,00% 4608 0,00%
61 System.Linq.Expressions.aotdata.arm64 499248 528056 5,77% 579376 16,05% 610776 22,34%
62 System.Linq.Expressions.dll 120320 120320 0,00% 120320 0,00% 120320 0,00%
63 System.Linq.aotdata.arm64 121560 150256 23,61% 226616 86,42% 275264 126,44%
64 System.Linq.dll 22528 22016 -2,27% 22016 -2,27% 22016 -2,27%
65 System.Memory.aotdata.arm64 824 824 0,00% 824 0,00% 824 0,00%
66 System.Memory.dll 4608 4096 -11,11% 4096 -11,11% 4096 -11,11%
67 System.Net.Http.aotdata.arm64 130696 226808 73,54% 278432 113,04% 311760 138,54%
68 System.Net.Http.dll 61440 61952 0,83% 61952 0,83% 61952 0,83%
69 System.Net.Primitives.aotdata.arm64 1424 1424 0,00% 1432 0,56% 1432 0,56%
70 System.Net.Primitives.dll 8704 8704 0,00% 8704 0,00% 8704 0,00%
71 System.Net.Requests.aotdata.arm64 928 928 0,00% 928 0,00% 928 0,00%
72 System.Net.Requests.dll 5632 5632 0,00% 5632 0,00% 5632 0,00%
73 System.Net.Security.aotdata.arm64 888 888 0,00% 888 0,00% 888 0,00%
74 System.Net.Security.dll 4608 5120 11,11% 5120 11,11% 5120 11,11%
75 System.Net.ServicePoint.aotdata.arm64 1960 1960 0,00% 1960 0,00% 1960 0,00%
76 System.Net.ServicePoint.dll 5632 5632 0,00% 5632 0,00% 5632 0,00%
77 System.Numerics.Vectors.aotdata.arm64 816 816 0,00% 816 0,00% 816 0,00%
78 System.Numerics.Vectors.dll 4608 4608 0,00% 4608 0,00% 4608 0,00%
79 System.ObjectModel.aotdata.arm64 10304 10720 4,04% 10720 4,04% 11112 7,84%
80 System.ObjectModel.dll 13312 13312 0,00% 13312 0,00% 13312 0,00%
81 System.Private.CoreLib.aotdata.arm64 1318848 1621832 22,97% 1694456 28,48% 1777432 34,77%
82 System.Private.CoreLib.dll 912384 932864 2,24% 935936 2,58% 934400 2,41%
83 System.Private.Uri.aotdata.arm64 81728 217696 166,37% 264696 223,87% 275344 236,90%
84 System.Private.Uri.dll 25600 26624 4,00% 26624 4,00% 26624 4,00%
85 System.Private.Xml.aotdata.arm64 229216 274304 19,67% 321376 40,21% 376784 64,38%
86 System.Private.Xml.dll 247296 248320 0,41% 248320 0,41% 248320 0,41%
87 System.Runtime.InteropServices.aotdata.arm64 840 840 0,00% 840 0,00% 840 0,00%
88 System.Runtime.InteropServices.dll 4608 4608 0,00% 4608 0,00% 4608 0,00%
89 System.Runtime.aotdata.arm64 808 808 0,00% 808 0,00% 808 0,00%
90 System.Runtime.dll 11776 11776 0,00% 11776 0,00% 11776 0,00%
91 System.Security.Cryptography.aotdata.arm64 43000 70408 63,74% 150304 249,54% 180640 320,09%
92 System.Security.Cryptography.dll 5632 5632 0,00% 5632 0,00% 5632 0,00%
93 System.Text.RegularExpressions.aotdata.arm64 520208 605448 16,39% 648656 24,69% 677736 30,28%
94 System.Text.RegularExpressions.dll 139264 139776 0,37% 139776 0,37% 139776 0,37%
95 System.Threading.Thread.aotdata.arm64 816 816 0,00% 816 0,00% 816 0,00%
96 System.Threading.Thread.dll 4096 4608 12,50% 4608 12,50% 4608 12,50%
97 System.Threading.aotdata.arm64 824 824 0,00% 824 0,00% 824 0,00%
98 System.Threading.dll 4608 4608 0,00% 4608 0,00% 4608 0,00%
99 System.Xml.ReaderWriter.aotdata.arm64 816 816 0,00% 816 0,00% 816 0,00%
100 System.Xml.ReaderWriter.dll 4608 4608 0,00% 4608 0,00% 4608 0,00%
101 System.aotdata.arm64 800 800 0,00% 800 0,00% 800 0,00%
102 System.dll 4096 4096 0,00% 4096 0,00% 4096 0,00%
103 _CodeSignature 96 96 0,00% 96 0,00% 96 0,00%
104 [email protected] 1361 1361 0,00% 1361 0,00% 1361 0,00%
105 appicon76x76@2x~ipad.png 1649 1649 0,00% 1649 0,00% 1649 0,00%
106 dotnet_bot.png 19036 19036 0,00% 19036 0,00% 19036 0,00%
107 [email protected] 41155 41155 0,00% 41155 0,00% 41155 0,00%
108 [email protected] 55868 55868 0,00% 55868 0,00% 55868 0,00%
109 icudt.dat 1824544 1859040 1,89% 1859040 1,89% 1859040 1,89%
110 runtimeconfig.bin 983 983 0,00% 983 0,00% 983 0,00%
111 splash.png 1554 1554 0,00% 1554 0,00% 1554 0,00%
112 [email protected] 2750 2750 0,00% 2750 0,00% 2750 0,00%
113 [email protected] 4776 4776 0,00% 4776 0,00% 4776 0,00%
TOTAL: 40598192 53890112 32,74% 66453040 63,68% 72477624 78,52%

@SamMonoRT
Copy link
Member

some of these are mitigated by the de-dup feature and other fixes. Moving this to 9.0.0

@SamMonoRT
Copy link
Member

@kotlarmilos once we have the updated numbers from automation, add them here.

@SamMonoRT SamMonoRT modified the milestones: 8.0.0, 9.0.0 Aug 3, 2023
@ivanpovazan
Copy link
Member Author

ivanpovazan commented Aug 3, 2023

some of these are mitigated by the de-dup feature and other fixes. Moving this to 9.0.0

With the latest measurements presented in xamarin/xamarin-macios#18555 we have ~4% smaller apps compared to .NET7 release. So, I believe we could close this issue even for 8.0.0 time frame. Nevertheless, we should wait for the PR to get merged and get the presented numbers in perf measurements.

@SamMonoRT
Copy link
Member

Closing issue based on above comments.

@ghost ghost locked as resolved and limited conversation to collaborators Sep 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Codegen-AOT-mono size-reduction Issues impacting final app size primary for size sensitive workloads
Projects
None yet
Development

No branches or pull requests

6 participants