Skip to content

build: added more options to optimize release binary size#91

Open
goto-dev-null wants to merge 2 commits intoDj-Codeman:masterfrom
goto-dev-null:optimize-release
Open

build: added more options to optimize release binary size#91
goto-dev-null wants to merge 2 commits intoDj-Codeman:masterfrom
goto-dev-null:optimize-release

Conversation

@goto-dev-null
Copy link

I am still a bit of a newb to Rust myself so I am not fully confident in the best opt-level to use, or to leave it as default (0). For doge, I'd be tempted to desire smaller binaries at the cost of performance; I'm not sure that its use case is one where you're going to see a noticeable change anyway...I tried to do some benchmarks with hyperfine and every command I ran (even with the opt-level "z" binary) ran in under 2.5ms.

Meanwhile, the reduction in binary in size, depending on the target, can be pretty significant.

Here are the numbers based on the v0.2.9 release and this run on my fork:

Target Before After Reduction
linux-x86_64 6.8M 6.6M 3%
linux-i686 5.1M 4.9M 4%
linux-aarch64 6.0M 5.2M 13%
linux-armv7 3.9M 3.1M 21%
apple 2.4M 1.9M 21%
windows-x86_64 1017K 864K 15%
windows-i686 779K 640K 18%

opt-level 3

Out of my own curiosity, I wanted to see the difference between opt-level = "z" and opt-level = 3. Here's the comparison for this run on my fork:

Target Before After Reduction
linux-x86_64 6.8M 6.7M 1%
linux-i686 5.1M 5.0 2%
linux-aarch64 6.0M 5.3M 12%
linux-armv7 3.9M 3.2M 18%
apple 2.4M 2.2M 8%
windows-x86_64 1017K 978K 4%
windows-i686 779K 752K 3%

So opt-level = "z" seems to be have way more of an affect on apple and windows and less on linux, which I find fascinating.

Copy link
Author

Choose a reason for hiding this comment

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

Unrelated typos I noticed but not really worth their own PR IMO

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.

1 participant