-
Notifications
You must be signed in to change notification settings - Fork 516
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
.NET: SingleView app size #10249
Comments
Shameless plug but you might want to use https://github.com/spouliot/dotnet-tools/tree/master/app-compare to compare the size of the current/dotnet apps |
Considering most of the device build time comes from the AOT compiler (at least in current form) then a 2x build time increase is not so bad as there's more than 3x more managed code (1,5 MB vs 460 KB) to AOT. IOW we can consider this the "same issue", unless the time increase comes from elsewhere. |
It looks like you don't have some of the feature switched enabled, see https://github.com/dotnet/runtime/blob/master/docs/workflow/trimming/feature-switches.md. I'm not saying that's all that needs to be done but it's a good start ;-) |
Application Comparer
|
other issues
update: both issues are fixed with P4 |
@spouliot could you share the binaries? |
@marek-safar yes but likely not today. My main internet connection is down :( and I'm waiting for a new modem to be delivered. Trying to limit myself to low bandwidth (cellular) tasks. |
#10250 - that shaves off a good chunk. |
I filed #10251 for this: just executing the .NET 6 linker takes longer than linking + AOT compilation + native compilation used to. |
This update was done with today's dotnet 6.0.100-preview.2.21158.2 build and xamarin-macios Most of the previous comments (e.g. extra files, no ICU in numbers) still applies. Noticeable/visible changes are:
It's a great improvement, over the original numbers, but there's still work to be done compared to the current SDK size. Application Comparer
|
@spouliot @rolfbjarne - do we know why That could contribute a lot to why .NET 6's CoreLib is bigger than mono's mscorlib. More code in higher level assemblies means the possibility of more code being rooted lower in corelib. |
No, at least not yet. I wanted numbers to go along P2 even if we did not have time to look at the results right away - they will have historical value ;-) Quick guess some of our optimizations were not yet ported/enabled (last time I checked).
That definitively plays its part. Still even if Xamarin.iOS.dll is huge (lots of bindings) there's not a lot of variety in the API being used. I'll dig up more useful data asap |
This comment has been minimized.
This comment has been minimized.
I took a quick look at the assembly last night and what I've seen is largely (still) disabled optimizations.
Only one (dynamic registrar) would have a significant impact on what's required inside UpdateI missed the most obvious - since I can see the IL of the dotnet version it means the |
Numbers from Notes:
Application Comparer
|
Results with the Major changes from P3 is that it includes the ICU data file Application Comparer
|
https://github.com/spouliot/appcompare#how-to-install
This is probably something that can be improved, these header files are not mandatory in .NET apps. An issue with a test project would help us look at this.
The easiest way to check if an assembly was linked is probably to check the size or md5 checksum of the assembly in the app bundle vs the one produced by the C# compiler earlier in the build. Unfortunately, the next step, figuring out why a particular assembly isn't linked away, is a rather involved process:
|
Small test project with reference to AdMob NuGet: test.zip
I commented out the (unused) class that referenced It appears that shared projects aren't handled correctly by the linked? |
That's weird. Have you tried from a new terminal window ? I don't recall if Alternatively you could clone the repo and built the tool.
Somehow, something had a reference to that type. It could be your app - but then it would fail to build when commented. It could be the linker that smartly detects JSON related types and decide to mark them since they are generally (if) used using reflection. |
Yes and I have also restarted macOS completely. I am using a Mac mini from 2020 if that is of relevance.
I included a repo project in my comment above. When I call |
@tipa speaking only of You can file [1] I'll let someone from Microsoft to answers the other issues, including where best to file them :) |
Yes, please file separate issues (in this repo, we'll move elsewhere if need be), that makes it much easier to handle them and not get confused (it's always easier to merge issues than it is to split an issue after everyone on the issue has become thoroughly confused). |
I filed those issues here: |
Update results: Short answer: we're 6,8mb bigger (~148%) in .NET 8 than .NET 7 vs legacy Xamarin. NativeAOT makes it a little bit better, only 2,6mb bigger (57%). Comparing .NET 7 vs .NET 8 yields that the .NET 8 is 2,4mb bigger (27%). .NET 7Commit: a7e96e5 https://gist.github.com/rolfbjarne/0591a45002e40e4086f9d3132233f8ed .NET 8Commit: bf77022 https://gist.github.com/rolfbjarne/f01885cc66050f7ddb72f4fdec9d21b5 .NET 8 with NativeAOTCommit: bf77022 https://gist.github.com/rolfbjarne/ffd61461a4565b75d7c231331e3d170b .NET 7 vs .NET 8https://gist.github.com/rolfbjarne/5d809f1fcc37852c922c47c54b8c79c8 |
Note that with NativeAOT we can use |
You can also mention that this tool |
Updated results: We're 2,2mb smaller (-19,6%) in .NET 9 vs .NET 8. The size decrease almost exactly matches the size increase from .NET 7 to .NET 8, so we're effectively back to where we were in .NET 7 size-wise. |
Is |
The hybrid globalization option is default in |
App sizes are currently significantly bigger with .NET 6 with a very simple hello world app.
Test case
xamarin-macios
cd tests/dotnet make compare
This will build a very simple hello world app for both .NET 6 and the old-style Xamarin.iOS and generate a report in markdown format. This can be pasted into the issue (e.g. for each preview) so the progress can be tracked.
Known Issues
System.Reflection
API (see below)Historical
App sizes
Xamarin.iOS
du -hs size-comparison/MySingleView/oldnet/bin/iPhone/Release/MySingleView.app
4.4M size-comparison/MySingleView/oldnet/bin/iPhone/Release/MySingleView.app
.NET 6
du -hs size-comparison/MySingleView/dotnet/bin/iPhone/Release/net6.0-ios/ios-arm64/*.app
27M size-comparison/MySingleView/dotnet/bin/iPhone/Release/net6.0-ios/ios-arm64/MySingleView.app
Assembly sizes
Xamarin.iOS
ls -lahS size-comparison/MySingleView/oldnet/bin/iPhone/Release/MySingleView.app/.dll size-comparison/MySingleView/oldnet/bin/iPhone/Release/MySingleView.app/.exe
-rw-r--r-- 1 rolf wheel 397K Dec 9 19:04 size-comparison/MySingleView/oldnet/bin/iPhone/Release/MySingleView.app/mscorlib.dll
-rw-r--r-- 1 rolf wheel 54K Dec 9 19:04 size-comparison/MySingleView/oldnet/bin/iPhone/Release/MySingleView.app/Xamarin.iOS.dll
-rw-r--r-- 1 rolf wheel 4.5K Dec 9 19:04 size-comparison/MySingleView/oldnet/bin/iPhone/Release/MySingleView.app/MySingleView.exe
-rw-r--r-- 1 rolf wheel 4.5K Dec 9 19:05 size-comparison/MySingleView/oldnet/bin/iPhone/Release/MySingleView.app/System.dll
.NET 6
ls -lahS size-comparison/MySingleView/dotnet/bin/iPhone/Release/net6.0-ios/ios-arm64/.app/.dll
-rw-r--r-- 1 rolf wheel 1.3M Dec 9 19:05 size-comparison/MySingleView/dotnet/bin/iPhone/Release/net6.0-ios/ios-arm64/MySingleView.app/System.Private.CoreLib.dll
-rw-r--r-- 1 rolf wheel 161K Dec 9 19:05 size-comparison/MySingleView/dotnet/bin/iPhone/Release/net6.0-ios/ios-arm64/MySingleView.app/Xamarin.iOS.dll
-rw-r--r-- 1 rolf wheel 17K Dec 9 19:05 size-comparison/MySingleView/dotnet/bin/iPhone/Release/net6.0-ios/ios-arm64/MySingleView.app/System.Runtime.dll
-rw-r--r-- 1 rolf wheel 16K Dec 9 19:05 size-comparison/MySingleView/dotnet/bin/iPhone/Release/net6.0-ios/ios-arm64/MySingleView.app/System.Runtime.Serialization.Formatters.dll
-rw-r--r-- 1 rolf wheel 5.0K Dec 9 19:05 size-comparison/MySingleView/dotnet/bin/iPhone/Release/net6.0-ios/ios-arm64/MySingleView.app/MySingleView.dll
There are multiple issues here:
The .NET 6 version has unnecessary dylibs (because it's linking libraries statically).fixThe .NET 6 version does not strip the native executable.Additionally the .NET 6 version takes twice as long to compile (22s vs 11s on my machine), but that's a different issue (filed as #10251).
The text was updated successfully, but these errors were encountered: