iroh icon indicating copy to clipboard operation
iroh copied to clipboard

optimize binary sizes

Open Arqu opened this issue 3 years ago • 1 comments

We currently run with defaults, we could do some work on reducing the final output sizes.

Arqu avatar Aug 08 '22 21:08 Arqu

There are quite a few crates that are compiled with several versions (3 versions of prost!) and reducing that is a way to reduce binary size (that also improves compile times). Run cargo tree -d -e=no-dev -e=no-build to see the dupes. Removing dupes is unfortunately often a chore when you have to get fixes in 3rd party crates that may not be very active or willing to publish new versions - you can live on forks of course but that comes with its price also.

On the pure built time configuration, using that release configuration in the workspace's Cargo.toml helps:

[profile.release]
codegen-units = 1
debug = false
debug-assertions = false
lto = true
opt-level = 3
panic = "abort"
rpath = false

With the gateway from the ipfsd branch (that also includes store & p2p):

  • No LTO, not stripped: -rwxr-xr-x 1 fabrice staff 36379978 Aug 11 14:59 iroh-gateway

  • No LTO, stripped: -rwxr-xr-x 1 fabrice staff 26338048 Aug 11 15:01 iroh-gateway

  • LTO, not stripped: -rwxr-xr-x 1 fabrice staff 25663914 Aug 11 15:09 iroh-gateway

  • LTO, stripped: -rwxr-xr-x 1 fabrice staff 19054704 Aug 11 15:12 iroh-gateway

fabricedesre avatar Aug 11 '22 22:08 fabricedesre