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

[illink] Set runtime libraries feature switches defaults #5337

Merged

Conversation

radekdoulik
Copy link
Member

Set all current feature switches, but InvariantGlobalization, to
defaults which trim the features.

Context: https://github.com/dotnet/runtime/blob/master/docs/workflow/trimming/feature-switches.md

Difference in assembly size of XA BuildReleaseArm64False test before/after:

Summary:
  -     417,632 Assemblies -15.98% (of 2,613,075)

Set all current feature switches, but `InvariantGlobalization`, to
defaults which trim the features.

Context: https://github.com/dotnet/runtime/blob/master/docs/workflow/trimming/feature-switches.md

Difference in apk size of XA BuildReleaseArm64False test before/after:

    Summary:
      -     417,632 Assemblies -15.98% (of 2,613,075)
@radekdoulik
Copy link
Member Author

Detailed comparison of the above mentioned apks

apkdiff -v -f -e dll bin\TestDebug\temp-current\BuildReleaseArm64False-net5\bin\Release\UnnamedProject.UnnamedProject.apk .\bin\TestDebug\temp\BuildReleaseArm64False-net5\bin\Release\UnnamedProject.UnnamedProject.apk
Loading apk 'bin\TestDebug\temp-current\BuildReleaseArm64False-net5\bin\Release\UnnamedProject.UnnamedProject.apk'
          2584 AndroidManifest.xml
          2200 res/drawable-mdpi-v4/icon.png
          4791 res/drawable-hdpi-v4/icon.png
          7462 res/drawable-xhdpi-v4/icon.png
         13092 res/drawable-xxhdpi-v4/icon.png
         20118 res/drawable-xxxhdpi-v4/icon.png
           544 res/layout/main.xml
          1724 resources.arsc
        317096 classes.dex
          3090 assemblies/UnnamedProject.dll
          3907 assemblies/Microsoft.Win32.Primitives.dll
         14620 assemblies/System.Collections.Concurrent.dll
          9962 assemblies/System.Collections.NonGeneric.dll
         11959 assemblies/System.Collections.dll
          4598 assemblies/System.ComponentModel.Primitives.dll
          9754 assemblies/System.Console.dll
         29064 assemblies/System.Diagnostics.DiagnosticSource.dll
         29154 assemblies/System.Formats.Asn1.dll
         13539 assemblies/System.IO.Compression.Brotli.dll
         23012 assemblies/System.IO.Compression.dll
         27844 assemblies/System.IO.FileSystem.dll
        137374 assemblies/System.Linq.Expressions.dll
         19966 assemblies/System.Linq.dll
        241474 assemblies/System.Net.Http.dll
         13562 assemblies/System.Net.NameResolution.dll
         19523 assemblies/System.Net.NetworkInformation.dll
         45803 assemblies/System.Net.Primitives.dll
         38243 assemblies/System.Net.Quic.dll
         84589 assemblies/System.Net.Security.dll
         66350 assemblies/System.Net.Sockets.dll
          7462 assemblies/System.ObjectModel.dll
         42614 assemblies/System.Private.Uri.dll
         12559 assemblies/System.Private.Xml.Linq.dll
        304668 assemblies/System.Private.Xml.dll
          1730 assemblies/System.Runtime.CompilerServices.Unsafe.dll
          3392 assemblies/System.Runtime.InteropServices.RuntimeInformation.dll
         23083 assemblies/System.Runtime.Numerics.dll
          7156 assemblies/System.Runtime.Serialization.Formatters.dll
          2895 assemblies/System.Runtime.Serialization.Primitives.dll
         47186 assemblies/System.Security.Cryptography.Algorithms.dll
         14530 assemblies/System.Security.Cryptography.Encoding.dll
         17874 assemblies/System.Security.Cryptography.OpenSsl.dll
         11589 assemblies/System.Security.Cryptography.Primitives.dll
        101449 assemblies/System.Security.Cryptography.X509Certificates.dll
         55708 assemblies/System.Text.RegularExpressions.dll
         16356 assemblies/System.Threading.Channels.dll
        820003 assemblies/System.Private.CoreLib.dll
         74995 assemblies/Java.Interop.dll
         18764 assemblies/Mono.Android.Export.dll
        181675 assemblies/Mono.Android.dll
         18104 lib/arm64-v8a/libxamarin-app.so
        250592 lib/arm64-v8a/libmonodroid.so
        776216 lib/arm64-v8a/libSystem.IO.Compression.Native.so
         71776 lib/arm64-v8a/libSystem.Native.so
        100464 lib/arm64-v8a/libSystem.Security.Cryptography.Native.OpenSsl.so
      17498904 lib/arm64-v8a/libmonosgen-2.0.so
         66544 lib/arm64-v8a/libxa-internal-api.so
        191408 lib/arm64-v8a/libxamarin-debug-app-helper.so
Loading apk '.\bin\TestDebug\temp\BuildReleaseArm64False-net5\bin\Release\UnnamedProject.UnnamedProject.apk'
          2584 AndroidManifest.xml
          2200 res/drawable-mdpi-v4/icon.png
          4791 res/drawable-hdpi-v4/icon.png
          7462 res/drawable-xhdpi-v4/icon.png
         13092 res/drawable-xxhdpi-v4/icon.png
         20118 res/drawable-xxxhdpi-v4/icon.png
           544 res/layout/main.xml
          1724 resources.arsc
        317096 classes.dex
          2956 assemblies/UnnamedProject.dll
          3835 assemblies/Microsoft.Win32.Primitives.dll
         10828 assemblies/System.Collections.Concurrent.dll
          7479 assemblies/System.Collections.NonGeneric.dll
          8526 assemblies/System.Collections.dll
          3194 assemblies/System.ComponentModel.Primitives.dll
          5958 assemblies/System.Console.dll
         26633 assemblies/System.Formats.Asn1.dll
         11943 assemblies/System.IO.Compression.Brotli.dll
         19223 assemblies/System.IO.Compression.dll
         24112 assemblies/System.IO.FileSystem.dll
        115284 assemblies/System.Linq.Expressions.dll
         18219 assemblies/System.Linq.dll
        214315 assemblies/System.Net.Http.dll
          9063 assemblies/System.Net.NameResolution.dll
         18198 assemblies/System.Net.NetworkInformation.dll
         42522 assemblies/System.Net.Primitives.dll
         37061 assemblies/System.Net.Quic.dll
         67928 assemblies/System.Net.Security.dll
         55915 assemblies/System.Net.Sockets.dll
          5153 assemblies/System.ObjectModel.dll
         40584 assemblies/System.Private.Uri.dll
         10317 assemblies/System.Private.Xml.Linq.dll
        250680 assemblies/System.Private.Xml.dll
          1666 assemblies/System.Runtime.CompilerServices.Unsafe.dll
          3007 assemblies/System.Runtime.InteropServices.RuntimeInformation.dll
         21740 assemblies/System.Runtime.Numerics.dll
          2648 assemblies/System.Runtime.Serialization.Formatters.dll
          2583 assemblies/System.Runtime.Serialization.Primitives.dll
         40626 assemblies/System.Security.Cryptography.Algorithms.dll
         11973 assemblies/System.Security.Cryptography.Encoding.dll
         14801 assemblies/System.Security.Cryptography.OpenSsl.dll
          9625 assemblies/System.Security.Cryptography.Primitives.dll
         92753 assemblies/System.Security.Cryptography.X509Certificates.dll
         52334 assemblies/System.Text.RegularExpressions.dll
         14374 assemblies/System.Threading.Channels.dll
        643953 assemblies/System.Private.CoreLib.dll
         74522 assemblies/Java.Interop.dll
         18638 assemblies/Mono.Android.Export.dll
        180274 assemblies/Mono.Android.dll
         18040 lib/arm64-v8a/libxamarin-app.so
        250592 lib/arm64-v8a/libmonodroid.so
        776216 lib/arm64-v8a/libSystem.IO.Compression.Native.so
         71776 lib/arm64-v8a/libSystem.Native.so
        100464 lib/arm64-v8a/libSystem.Security.Cryptography.Native.OpenSsl.so
      17498904 lib/arm64-v8a/libmonosgen-2.0.so
         66544 lib/arm64-v8a/libxa-internal-api.so
        191408 lib/arm64-v8a/libxamarin-debug-app-helper.so
Size difference in bytes ([*1] apk1 only, [*2] apk2 only):
  -          64 assemblies/System.Runtime.CompilerServices.Unsafe.dll
  -          72 assemblies/Microsoft.Win32.Primitives.dll
  -         126 assemblies/Mono.Android.Export.dll
  -         134 assemblies/UnnamedProject.dll
  -         312 assemblies/System.Runtime.Serialization.Primitives.dll
  -         385 assemblies/System.Runtime.InteropServices.RuntimeInformation.dll
  -         473 assemblies/Java.Interop.dll
  -       1,182 assemblies/System.Net.Quic.dll
  -       1,325 assemblies/System.Net.NetworkInformation.dll
  -       1,343 assemblies/System.Runtime.Numerics.dll
  -       1,401 assemblies/Mono.Android.dll
  -       1,404 assemblies/System.ComponentModel.Primitives.dll
  -       1,596 assemblies/System.IO.Compression.Brotli.dll
  -       1,747 assemblies/System.Linq.dll
  -       1,964 assemblies/System.Security.Cryptography.Primitives.dll
  -       1,982 assemblies/System.Threading.Channels.dll
  -       2,030 assemblies/System.Private.Uri.dll
  -       2,242 assemblies/System.Private.Xml.Linq.dll
  -       2,309 assemblies/System.ObjectModel.dll
  -       2,483 assemblies/System.Collections.NonGeneric.dll
  -       2,521 assemblies/System.Formats.Asn1.dll
  -       2,557 assemblies/System.Security.Cryptography.Encoding.dll
  -       3,073 assemblies/System.Security.Cryptography.OpenSsl.dll
  -       3,281 assemblies/System.Net.Primitives.dll
  -       3,374 assemblies/System.Text.RegularExpressions.dll
  -       3,433 assemblies/System.Collections.dll
  -       3,732 assemblies/System.IO.FileSystem.dll
  -       3,789 assemblies/System.IO.Compression.dll
  -       3,792 assemblies/System.Collections.Concurrent.dll
  -       3,796 assemblies/System.Console.dll
  -       4,499 assemblies/System.Net.NameResolution.dll
  -       4,508 assemblies/System.Runtime.Serialization.Formatters.dll
  -       6,560 assemblies/System.Security.Cryptography.Algorithms.dll
  -       8,696 assemblies/System.Security.Cryptography.X509Certificates.dll
  -      10,435 assemblies/System.Net.Sockets.dll
  -      16,661 assemblies/System.Net.Security.dll
  -      22,090 assemblies/System.Linq.Expressions.dll
  -      27,159 assemblies/System.Net.Http.dll
  -      29,064 assemblies/System.Diagnostics.DiagnosticSource.dll *1
  -      53,988 assemblies/System.Private.Xml.dll
  -     176,050 assemblies/System.Private.CoreLib.dll
Summary:
  apk1:      9470449  bin\TestDebug\temp-current\BuildReleaseArm64False-net5\bin\Release\UnnamedProject.UnnamedProject.apk
  apk2:      9052603  .\bin\TestDebug\temp\BuildReleaseArm64False-net5\bin\Release\UnnamedProject.UnnamedProject.apk
  -     417,632 Assemblies -15.98% (of 2,613,075)
  -     417,846 Package size difference -4.41% (of 9,470,449)

@radekdoulik
Copy link
Member Author

@rolfbjarne do you set these feature switches for iOS as well?

Remove `System.Diagnostics.DiagnosticSource.dll` from the list, as it is
now linked away as it should be.
Copy link
Member

@jonathanpeppers jonathanpeppers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, I restarted the MBuild device tests.

The CheckIncludedAssemblies test that is failing because of Mono.Android.Export.dll happens on master, so it is unrelated.

@radekdoulik radekdoulik merged commit d22f04e into dotnet:master Dec 1, 2020
rolfbjarne added a commit to rolfbjarne/xamarin-macios that referenced this pull request Dec 10, 2020
Set all current feature switches, except for InvariantGlobalization, to
defaults which trim the features.

Ref: https://github.com/dotnet/runtime/blob/master/docs/workflow/trimming/feature-switches.md
Ref: dotnet/android#5337

This drops the hello world app size from 28.6 MB to 23.5 MB. Full report:
https://gist.github.com/rolfbjarne/71cc18b49446862f1d42aa29526b0ac6
rolfbjarne added a commit to xamarin/xamarin-macios that referenced this pull request Dec 10, 2020
Set all current feature switches, except for InvariantGlobalization, to
defaults which trim the features.

Ref: https://github.com/dotnet/runtime/blob/master/docs/workflow/trimming/feature-switches.md
Ref: dotnet/android#5337

This drops the hello world app size from 28.6 MB to 23.5 MB. Full report:
https://gist.github.com/rolfbjarne/71cc18b49446862f1d42aa29526b0ac6
@github-actions github-actions bot locked and limited conversation to collaborators Jan 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants