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

Allow more effective trimming #191

Merged
merged 1 commit into from
Dec 22, 2024
Merged

Conversation

AArnott
Copy link
Owner

@AArnott AArnott commented Dec 22, 2024

Instead of instantiating all built-in converters on startup unconditionally or referencing all the supported data types themselves, use a generic method so that the JIT will remove references to data types (and their converters) that are never serialized in the application.

It may not be intuitive, but indeed a long C# method of type checks does offer this trim optimization, because the JIT / AOT compiler will remove type checks that will never match given the type argument on the generic method, thereby removing the unrelated type references, leaving only those behind that are actually going to be used.

Accrues toward #190, by bringing the AOT console test app down from 3.9MB to just under 3.6MB.

Instead of instantiating all built-in converters on startup unconditionally or referencing all the supported data types themselves, use a generic method so that the JIT will remove references to data types (and their converters) that are never serialized in the application.

It may not be intuitive, but indeed a long C# method of type checks _does_ offer this trim optimization, because the JIT / AOT compiler will remove type checks that will never match given the type argument on the generic method, thereby removing the unrelated type references, leaving only those behind that are actually going to be used.

Accrues toward #190, by bringing the AOT console test app down from 3.9MB to just under 3.6MB.
@AArnott AArnott linked an issue Dec 22, 2024 that may be closed by this pull request
@AArnott AArnott enabled auto-merge December 22, 2024 23:12
@AArnott AArnott merged commit 89a2261 into main Dec 22, 2024
2 checks passed
@AArnott AArnott deleted the 190-bring-down-trimmed-application-size branch December 22, 2024 23:16
Copy link

codecov bot commented Dec 22, 2024

Codecov Report

Attention: Patch coverage is 97.14286% with 3 lines in your changes missing coverage. Please review.

Project coverage is 83.72%. Comparing base (ed14d81) to head (0a1f7f0).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...MessagePack/Converters/PrimitiveConverterLookup.cs 97.08% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #191      +/-   ##
==========================================
+ Coverage   83.70%   83.72%   +0.01%     
==========================================
  Files         156      157       +1     
  Lines       12485    12546      +61     
  Branches     1283     1239      -44     
==========================================
+ Hits        10451    10504      +53     
- Misses       2012     2021       +9     
+ Partials       22       21       -1     
Flag Coverage Δ
Linux ?
Windows 83.72% <97.14%> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bring down trimmed application size
1 participant