Skip to content

Commit

Permalink
Merge pull request #1 from pavelsavara/smaller
Browse files Browse the repository at this point in the history
more trimming, no AOT
  • Loading branch information
DamianEdwards authored Dec 19, 2024
2 parents 5322f57 + bca1a59 commit f0b72ba
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 0 deletions.
15 changes: 15 additions & 0 deletions ClientSideValidator/ClientSideValidator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,24 @@
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<!-- Mono AOT is generally producing bigger downloads than the same app with interpreter
<RunAOTCompilation>true</RunAOTCompilation>
-->

<WasmStripILAfterAOT>true</WasmStripILAfterAOT>
<InvariantGlobalization>true</InvariantGlobalization>
<InvariantTimezone>true</InvariantTimezone>

<DebuggerSupport>false</DebuggerSupport>
<WasmEnableSIMD>false</WasmEnableSIMD>
<DynamicCodeSupport>false</DynamicCodeSupport>

<EnableAggressiveTrimming>true</EnableAggressiveTrimming>
<PublishTrimmed>true</PublishTrimmed>
<TrimMode>full</TrimMode>
<_ExtraTrimmerArgs>$(_ExtraTrimmerArgs) --substitutions "$(MSBuildThisFileDirectory)ILLink.Substitutions.xml"</_ExtraTrimmerArgs>

<!-- for the analysis see ./obj/Release/net9.0/linked/linker-dependencies.xml -->
<_TrimmerDumpDependencies>true</_TrimmerDumpDependencies>
</PropertyGroup>
</Project>
71 changes: 71 additions & 0 deletions ClientSideValidator/ILLink.Substitutions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<linker>
<!--
I randomly trimmed methods which I believe are not necessary for this demo.
For example, System.UriTypeConverter -> System.Uri is worth 60kb after compression.
Other good gains which I didn't do in System.ComponentModel could be:
- replacing ConcurrentDictionary with Dictionary since browser is not multi-threaded
- avoid using reflection, like System.ComponentModel.ReflectTypeDescriptionProvider
- trim unnecessary System.ComponentModel.*Converter
For more please see ./obj/Release/net9.0/linked/linker-dependencies.xml and use analysis tools.
https://github.com/dotnet/runtime/blob/main/src/tools/illink/src/analyzer/README.md#how-to-use-the-analyzer
-->
<assembly fullname="System.Private.CoreLib">
<type fullname="Mono.HotReload.FieldStore">
<method signature="Mono.HotReload.FieldStore Create(System.RuntimeTypeHandle)" body="remove"/>
</type>
<type fullname="Mono.HotReload.InstanceFieldTable/InstanceFields">
<method signature="Mono.HotReload.FieldStore LookupOrAdd(System.RuntimeTypeHandle,System.UInt32)" body="remove"/>
</type>
<type fullname="System.TimeZoneInfo">
<method signature="System.Boolean TryGetLocalTzFile(System.Byte[]&amp;,System.String&amp;)" body="remove"/>
<method signature="System.TimeZoneInfo get_Local()" body="remove"/>
</type>
<type fullname="Interop/Sys">
<method signature="System.Int32 Unlink(System.String)" body="remove"/>
</type>
<type fullname="System.Threading.Tasks.Task">
<method signature="System.Boolean InternalWait(System.Int32,System.Threading.CancellationToken)" body="remove"/>
</type>
<type fullname="System.Threading.Thread">
<method signature="System.Void Sleep(System.Int32)" body="remove"/>
</type>
<type fullname="System.Diagnostics.StackTrace">
<method signature="System.Void .ctor(System.Boolean)" body="remove"/>
<method signature="System.String ToString(System.Diagnostics.StackTrace/TraceFormat)" body="remove"/>
</type>
<type fullname="System.Runtime.Loader.AssemblyLoadContext">
<method signature="System.Reflection.RuntimeAssembly ResolveSatelliteAssembly(System.Reflection.AssemblyName)" body="remove"/>
<method signature="System.Reflection.RuntimeAssembly MonoResolveUsingResolveSatelliteAssembly(System.IntPtr,System.String)" body="remove"/>
</type>
</assembly>
<assembly fullname="System.Runtime.InteropServices.JavaScript">
<type fullname="System.Runtime.InteropServices.JavaScript.JSMarshalerArgument">
<method signature="System.Void ToJS(System.Object)" body="remove"/>
<method signature="System.Void ToJS(System.Object[])" body="remove"/>
</type>
<type fullname="System.Runtime.InteropServices.JavaScript.JavaScriptExports">
<method signature="System.Void LoadLazyAssembly(System.Runtime.InteropServices.JavaScript.JSMarshalerArgument*)" body="remove"/>
<method signature="System.Void LoadSatelliteAssembly(System.Runtime.InteropServices.JavaScript.JSMarshalerArgument*)" body="remove"/>
<method signature="System.Void GetManagedStackTrace(System.Runtime.InteropServices.JavaScript.JSMarshalerArgument*)" body="remove"/>
<method signature="System.Void DumpAotProfileData(System.Byte&amp;,System.Int32,System.String)" body="remove"/>
</type>
</assembly>
<assembly fullname="System.ComponentModel.TypeConverter">
<type fullname="System.UriTypeConverter">
<method signature="System.UriKind GetUriKind(System.Uri)" body="remove"/>
<method signature="System.Object ConvertFrom(System.ComponentModel.ITypeDescriptorContext,System.Globalization.CultureInfo,System.Object)" body="remove"/>
<method signature="System.Object ConvertTo(System.ComponentModel.ITypeDescriptorContext,System.Globalization.CultureInfo,System.Object,System.Type)" body="remove"/>
</type>
<type fullname="System.ComponentModel.CultureInfoConverter">
<method signature="System.Object ConvertFrom(System.ComponentModel.ITypeDescriptorContext,System.Globalization.CultureInfo,System.Object)" body="remove"/>
<method signature="System.Object ConvertTo(System.ComponentModel.ITypeDescriptorContext,System.Globalization.CultureInfo,System.Object,System.Type)" body="remove"/>
</type>
<type fullname="System.ComponentModel.VersionConverter">
<method signature="System.Object ConvertFrom(System.ComponentModel.ITypeDescriptorContext,System.Globalization.CultureInfo,System.Object)" body="remove"/>
<method signature="System.Object ConvertTo(System.ComponentModel.ITypeDescriptorContext,System.Globalization.CultureInfo,System.Object,System.Type)" body="remove"/>
</type>
</assembly>
</linker>

0 comments on commit f0b72ba

Please sign in to comment.