-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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: many more corelib symbols are materialized/AOT compiled in netcore compared to legacy Mono #56385
Comments
We'll keep working on this, but nothing concrete is expected to be checked in the 6.0.0 timeframe. Moving to 7.0.0 |
This is mostly a note to myself to do more followup work. I don't know why the .NET core corelib is resulting in twice as much stuff being compiled. |
@eerhardt Do you have any suggestions or ideas on what might be causing the increase in CoreLib size, or any pointers for directions to go when investigating? As far as I know we're doing some .NET-level dead code elimination via the managed linker, but I have no firsthand experience with this tool. |
One easy way to investigate is to use something like ILSpy to look into both assemblies to see what's in both. However, diffing is hard here because it doesn't diff assemblies. So you'd be able to spot high-level things using this method. Another approach I've used in the past is to use the API reviewer tool - Other tools that can be used to investigate where IL size is being used: https://github.com/dotnet/linker/tree/main/src/analyzer |
After some further analysis the following stats have been gathered by comparing:
builds of Analysisbloaty was used to generate symbols from both binaries respectively:
bloaty -d segments,sections,symbols --debug-file=dotnet/bin/iPhone/Release/net6.0-ios/ios-arm64/MySingleView.app.dSYM/Contents/Resources/DWARF/MySingleView dotnet/bin/iPhone/Release/net6.0-ios/ios-arm64/MySingleView.app/MySingleView -n 0 --tsv > ../logs/dotnet_symbols.list
bloaty -d segments,sections,symbols --debug-file=oldnet/bin/iPhone/Release/MySingleView.app.dSYM/Contents/Resources/DWARF/MySingleView oldnet/bin/iPhone/Release/MySingleView.app/MySingleView -n 0 --tsv > ../logs/oldnet_symbols.list Bloaty outputs were then further broken down by a script for easier analysis of the
ObservationWhat can be observed from the generated reports is that there are many more symbols in the
However, after inspecting just generic methods it can be seen that there a following difference:
Since generics take around %15 of the total app size, I was wondering whether some optimisations mentioned here (especially the point regarding usage of gsharedvt versions of a method) could help reduce the app size. (UPDATE: I have updated the numbers for generics since they were not precise enough ie I did not take into account generics with T1, T2, T3, T4 types - this does not drastically change the overall analysis.) @vargaz what do you think? |
Mostly note to myself. Further analysis has been performed on the output generated by The script reads the bloaty
Diff reports include symbols that are new in
Most interesting one is |
@ivanpovazan which runtime version is this using? There are many methods which I cannot find in main. |
@marek-safar UPDATE: I have corrected the --------------------------------------------------------------------------------------------------------------------------------------------
Symbol namespaces: size/name
--------------------------------------------------------------------------------------------------------------------------------------------
-238896 System
-177176 System_Numerics
-130484 System_Globalization
-115992 System_Threading
-82100 System_Collections_Generic
-73328 System_Threading_Tasks
-66220 System_Runtime_Intrinsics
-36748 System_Runtime_CompilerServices
-33320 System_Text
-19692 System_IO_Strategies
-16872 System_Buffers
-16448 System_Reflection
-15284 System_IO
+288272 System
+220388 System_Numerics
+137008 System_Globalization
+126072 System_Threading
+115672 System_Collections_Generic
+89896 System_Threading_Tasks
+75748 System_Runtime_Intrinsics
+59796 System_Runtime_CompilerServices
+38192 System_Text
+24316 System_IO_Strategies
+19784 System_Buffers
+18220 System_Collections_Concurrent
+17120 System_Reflection
+15720 System_IO
10412 System_Text_Unicode
-8204 System_Collections_Concurrent
-7892 System_Runtime_InteropServices
+10052 System_Runtime_InteropServices
7596 System_Diagnostics
-5972 System_Runtime_Loader
+6504 System_Runtime_Loader
4452 System_Reflection_Emit
1020 System_Diagnostics_Tracing
1016 System_Runtime_Serialization |
Here is the first comparison report comparing legacy with .NET 7 Mono for
New diff reports (generated as described in previous comments) and can be found here: |
The Scalar class is used to implement the fallback code for the vector classes, and Scalar are the gsharedvt versions of these methods. The code in Scalar is designed to be specialized, so the gsharedvt versions are very large/slow. |
The code handles only primitive types, everything else throws NotSupportedException. I'm not sure how to best handle this but gsharedvt version should not exist at all or always throw. |
@marek-safar, agreed. |
Closing this issue as it is outdated and all 3 dependent tasks have been move to the newer - .NET8 tracking issue: #80938 |
Original description
Seen while investigating size differences between legacy Mono and netcore Mono when used for iOS.
More details are forthcoming--and P7 apparently generates larger binaries than P6. A tsv containing size information for the P6 singleview app is available here: xamarin/xamarin-macios#10249 (comment)
I'll provide P7 and legacy (for comparison) breakdowns soon.
Curent state
We continued to investigate the size reduction issue in .NET 7 and identified the following work items to reflect the problem:
The text was updated successfully, but these errors were encountered: