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

"hello world" binary size increase in each release #75804

Closed
tesuji opened this issue Aug 22, 2020 · 7 comments
Closed

"hello world" binary size increase in each release #75804

tesuji opened this issue Aug 22, 2020 · 7 comments
Labels
C-bug Category: This is a bug. I-heavy Issue: Problems and improvements with respect to binary size of generated code. ICEBreaker-Cleanup-Crew Helping to "clean up" bugs with minimal examples and bisections P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@tesuji
Copy link
Contributor

tesuji commented Aug 22, 2020

The binary size of "hello world" program increased in each release:
image
image

Detail table
Rust version debug debug - stripped release release - stripped
1.32.0 2382904 199096 2375720 199016
1.40.0 2595400 215464 2588264 215384
1.41.0 2637336 215464 2629832 215384
1.42.0 2659672 211368 2652488 211288
1.43.0 2729192 223584 2722128 223504
1.44.0 2584120 248160 2579144 248080
1.45.0 2847440 244064 2842464 243984
beta 2848152 244064 2843168 243984
nightly 3210208 293200 3203712 293112
main.rs
fn main() {
    println!("hello world");
}
Script to reproduce
rustup set profile minimal
rustup toolchain install 1.{40..45}.0 beta nightly

RUST_DBG_FLAGS='-C debuginfo=1 -C panic=abort -C opt-level=0'
RUST_REL_FLAGS='-C debuginfo=0 -C panic=abort -C opt-level=3'

mkdir -p build/debug
mkdir -p build/release
for ver in 1.{40..45}.0 beta nightly; do
    bin_dbg=build/debug/main-$ver
    bin_rel=build/release/main-$ver
    rustc +$ver $RUST_DBG_FLAGS main.rs -o $bin_dbg
    echo "-- $ver"
    before=$(stat --printf="%s" $bin_dbg)
    strip $bin_dbg
    after=$(stat --printf="%s" $bin_dbg)
    printf "    dbg: %d, stripped: %d\n" $before $after

    rustc +$ver $RUST_REL_FLAGS main.rs -o $bin_rel
    before=$(stat --printf="%s" $bin_rel)
    strip $bin_rel
    after=$(stat --printf="%s" $bin_rel)
    printf "    release: %d, stripped: %d\n" $before $after
done

# rustup toolchain uninstall 1.{40..45}.0 beta nightly

Meta

beta:

rustc 1.46.0-beta.5 (cfbc6d4cf 2020-08-21)
binary: rustc
commit-hash: cfbc6d4cf1acbac5c025acf8ed68929caa551df3
commit-date: 2020-08-21
host: x86_64-unknown-linux-gnu
release: 1.46.0-beta.5
LLVM version: 10.0

nightly:

rustc 1.47.0-nightly (de521cbb3 2020-08-21)
binary: rustc
commit-hash: de521cbb303c08febd9fa3755caccd4f3e491ea3
commit-date: 2020-08-21
host: x86_64-unknown-linux-gnu
release: 1.47.0-nightly
LLVM version: 10.0
@tesuji tesuji added the C-bug Category: This is a bug. label Aug 22, 2020
@rustbot rustbot added I-heavy Issue: Problems and improvements with respect to binary size of generated code. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 22, 2020
@Mark-Simulacrum Mark-Simulacrum added the regression-from-stable-to-stable Performance or correctness regression from one stable version to another. label Aug 22, 2020
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Aug 22, 2020
@spastorino
Copy link
Member

Assigning P-medium as discussed as part of the Prioritization Working Group procedure and removing I-prioritize.

Would be nice to see where (if it's just one PR) this has regressed ...

@rustbot ping cleanup

And also if this affects more complex programs too.

For now considering it as P-medium but feel free to re-assign a different priority or comment on the issue explaining why should we prioritize it higher.

@rustbot rustbot added the ICEBreaker-Cleanup-Crew Helping to "clean up" bugs with minimal examples and bisections label Aug 27, 2020
@rustbot
Copy link
Collaborator

rustbot commented Aug 27, 2020

Hey Cleanup Crew ICE-breakers! This bug has been identified as a good
"Cleanup ICE-breaking candidate". In case it's useful, here are some
instructions for tackling these sorts of bugs. Maybe take a look?
Thanks! <3

cc @AminArria @camelid @chrissimpkins @contrun @DutchGhost @elshize @ethanboxx @h-michael @HallerPatrick @hdhoang @hellow554 @imtsuki @kanru @KarlK90 @LeSeulArtichaut @MAdrianMattocks @matheus-consoli @mental32 @nmccarty @Noah-Kennedy @pard68 @PeytonT @pierreN @Redblueflame @RobbieClarken @RobertoSnap @robjtede @SarthakSingh31 @senden9 @shekohex @sinato @spastorino @turboladen @woshilapin @yerke

@spastorino spastorino added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Aug 27, 2020
@tesuji
Copy link
Contributor Author

tesuji commented Aug 27, 2020

I think a high regression in nightly is from #74682 . Not that I think we should revert it, but it is worth investigating
to improve the situation somehow.

@eddyp
Copy link
Contributor

eddyp commented Feb 15, 2021

I just saw this on Windows (x86_64-pc-windows-msvc) in one of my applications on the upgrade from 1.49 to 1.50 and explored if this issue is known and reported.

c:\>rustup toolchain list
stable-x86_64-pc-windows-msvc (default)
beta-x86_64-pc-windows-msvc
nightly-x86_64-pc-windows-msvc
1.45-x86_64-pc-windows-msvc
1.46-x86_64-pc-windows-msvc
1.47-x86_64-pc-windows-msvc
1.48-x86_64-pc-windows-msvc
1.49-x86_64-pc-windows-msvc
1.50-x86_64-pc-windows-msvc

I just did a adaptation of the script to run on windows using cygwin (not using WSL as that would pick up Linux's version and I'm interested in Windows for this particular app).

I installed all versions since 1.45 (I didn't force the usage of 1.x.0), cygwin's strip has no effect on the binaries, so kept only one column.

I got these results:

image

  debug release
1.45 152.064 149.504
1.46 151.040 148.992
1.47 151.040 148.480
1.48 151.040 147.968
1.49 152.064 148.992
1.50 153.088 150.016
beta 146.944 144.384
nightly 146.944 144.384

@hellow554
Copy link
Contributor

Can anybody explain why there is a huge drop in current beta? 😊

@eddyp
Copy link
Contributor

eddyp commented Feb 15, 2021

Also similar results on my application (on x86_64-pc-windows-msvc) which is a parser using pest:

image

Sizes are as follow:

  debug release
1.45 614.400 175.104
1.46 608.256 175.104
1.47 605.696 175.616
1.48 604.672 168.960
1.49 576.000 170.496
1.50 573.440 173.056
beta 574.464 170.496
nightly 577.024 171.008

The Cargo.lock I have has some slightly older versions pinned but I don't think it shouldn't matter as clearly the compiler affects the size. For reference here are the crates my app depends on:

Compiling proc-macro2 v1.0.24
Compiling unicode-xid v0.2.1
Compiling ucd-trie v0.1.3
Compiling syn v1.0.60
Compiling maplit v1.0.2
Compiling unindent v0.1.7
Compiling pest v2.1.3
Compiling indoc v1.0.3
Compiling quote v1.0.9
Compiling pest_meta v2.1.3
Compiling pest_generator v2.1.3
Compiling pest_derive v2.1.0

L.E.: if older versions of the crates below, only the nightly debug is 576.512 instead of 577.024, but the others are exactly the same:

 Updating byteorder v1.3.4 -> v1.4.2
 Updating quote v1.0.8 -> v1.0.9
 Updating syn v1.0.58 -> v1.0.60

@tesuji
Copy link
Contributor Author

tesuji commented Apr 28, 2024

Closed as this seems to be taken care by https://perf.rust-lang.org/index.html.

@tesuji tesuji closed this as completed Apr 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. I-heavy Issue: Problems and improvements with respect to binary size of generated code. ICEBreaker-Cleanup-Crew Helping to "clean up" bugs with minimal examples and bisections P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants