I saved 475 MB out of the 895 MB used by a real-world Rust program by changing the layout of some structs and the way I was deserializing JSON files.
The real use case
My program deserializes all the JSON files of https://github.com/awslabs/aws-sdk-rust/tree/main/aws-models into "Smithy Shape" structs.
Those files contain thousands of structures similar to this one:
"com.amazonaws.iam#EnableOrganizationsRootSessionsResponse" : { "type" : "structure" , "members" : { "OrganizationId" : { "target" : "com.amazonaws.iam#OrganizationIdType" , "traits" : { "smithy.api#documentation" : "<p>The unique identifier (ID) of an organization.</p>" } }, "EnabledFeatures" : { "target" : "com.amazonaws.iam#FeaturesListType" , "traits" : { "smithy.api#documentation" : "<p>The features you have enabled for centralized root access.</p>" } } }, "traits" : { "smithy.api#output" : {} } },
As is common in Rust, my program uses the very convenient serde .
I won't go into every details, but part of the structure needs to be…