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

Generate SslConnectionInfo.Unix.cs with T4 template #84690

Merged
merged 21 commits into from Apr 17, 2023

Conversation

am11
Copy link
Member

@am11 am11 commented Apr 12, 2023

Instead of generating a huge static dictionary and runtime lookup, we can directly generate a switch-case chain.

System_Net_Security_System_Net_Security_TlsCipherSuiteData___cctor is the largest method in terms of code size.

This PR removes the cctor and inlines the value assignment. It shaves off 18.3 K from the final NativeAOT published binary.

# on osx-arm64

# prereqs
## $ dotnet tool install -g dotnet-t4 -a arm64
## $ cd runtime
## $ t4 src/libraries/System.Net.Security/src/System/Net/Security/SslConnectionInfo.Unix.tt -o src/libraries/System.Net.Security/src/System/Net/Security/SslConnectionInfo.Unix.cs

# build required subsets to publish CG2 with map file
$ ./build.sh clr+libs+packs -c Release -p:IlcGenerateMapFile=true

# top 50 largest methods
$ xmlstarlet sel -t -m "//ObjectNodes/MethodCode" -v 'concat(@Length, ": ", @Name)' -n artifacts/obj/coreclr/crossgen2/arm64/Release/native/crossgen2.map.xml | sort -nr | head -50

@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label Apr 12, 2023
@ghost
Copy link

ghost commented Apr 12, 2023

Tagging subscribers to this area: @dotnet/ncl, @bartonjs, @vcsjones
See info in area-owners.md if you want to be subscribed.

Issue Details

Instead of generating a huge static dictionary and runtime lookup, we can directly generate a switch-case chain.

System_Net_Security_System_Net_Security_TlsCipherSuiteData___cctor is the largest method in terms of code size.

This PR removes the cctor and inlines the value assignment. It shaves off 18.3 K from the final NativeAOT published binary.

# on osx-arm64

# prereqs
## $ dotnet tool install -g dotnet-t4 -a arm64
## $ cd runtime
## $ t4 src/libraries/System.Net.Security/src/System/Net/Security/SslConnectionInfo.Unix.tt -o src/libraries/System.Net.Security/src/System/Net/Security/SslConnectionInfo.Unix.cs

# build required subsets to publish CG2 with map file
$ ./build.sh clr+libs+packs -c Release -p:IlcGenerateMapFile=true

# top 50 largest methods
$ xmlstarlet sel -t -m "//ObjectNodes/MethodCode" -v 'concat(@Length, ": ", @Name)' -n artifacts/obj/coreclr/crossgen2/arm64/Release/native/crossgen2.map.xml | sort -nr | head -50
Author: am11
Assignees: -
Labels:

area-System.Net.Security, community-contribution

Milestone: -

@am11 am11 added the size-reduction Issues impacting final app size primary for size sensitive workloads label Apr 12, 2023
@ghost
Copy link

ghost commented Apr 12, 2023

Tagging subscribers to 'size-reduction': @eerhardt, @SamMonoRT, @marek-safar
See info in area-owners.md if you want to be subscribed.

Issue Details

Instead of generating a huge static dictionary and runtime lookup, we can directly generate a switch-case chain.

System_Net_Security_System_Net_Security_TlsCipherSuiteData___cctor is the largest method in terms of code size.

This PR removes the cctor and inlines the value assignment. It shaves off 18.3 K from the final NativeAOT published binary.

# on osx-arm64

# prereqs
## $ dotnet tool install -g dotnet-t4 -a arm64
## $ cd runtime
## $ t4 src/libraries/System.Net.Security/src/System/Net/Security/SslConnectionInfo.Unix.tt -o src/libraries/System.Net.Security/src/System/Net/Security/SslConnectionInfo.Unix.cs

# build required subsets to publish CG2 with map file
$ ./build.sh clr+libs+packs -c Release -p:IlcGenerateMapFile=true

# top 50 largest methods
$ xmlstarlet sel -t -m "//ObjectNodes/MethodCode" -v 'concat(@Length, ": ", @Name)' -n artifacts/obj/coreclr/crossgen2/arm64/Release/native/crossgen2.map.xml | sort -nr | head -50
Author: am11
Assignees: -
Labels:

area-System.Net.Security, size-reduction, community-contribution

Milestone: -

Copy link
Member

@rzikm rzikm left a comment

Choose a reason for hiding this comment

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

LGTM from System.Net.Security perspective.

Does it improve the size of regular System.Net.Security.dll binary as well?

Would prefer to have jkotas to have a look on this PR before merging.

@SamMonoRT
Copy link
Member

cc @ivanpovazan

@jkotas
Copy link
Member

jkotas commented Apr 16, 2023

Looks great otherwise - thank you!

@jkotas
Copy link
Member

jkotas commented Apr 17, 2023

enterprise-linux failure is #84795

@jkotas jkotas merged commit f92b9ef into dotnet:main Apr 17, 2023
105 of 107 checks passed
@dotnet dotnet locked as resolved and limited conversation to collaborators May 17, 2023
@karelz karelz added this to the 8.0.0 milestone May 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Net.Security community-contribution Indicates that the PR has been added by a community member size-reduction Issues impacting final app size primary for size sensitive workloads
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants