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

Investigate the size of the binary #1060

Closed
windelbouwman opened this issue Jun 26, 2019 · 8 comments
Closed

Investigate the size of the binary #1060

windelbouwman opened this issue Jun 26, 2019 · 8 comments

Comments

@windelbouwman
Copy link
Contributor

Our builds are rather large at this point. The release build is 18MB, the debug build is 89MB. This is rather big, and slows things down. What is the cause of this code size?

@windelbouwman
Copy link
Contributor Author

Does anyone have good resources / online manuals on how to investigate code size?

@coolreader18
Copy link
Member

I know of cargo-bloat

@apatrushev
Copy link

Does anyone have good resources / online manuals on how to investigate code size?

https://github.com/johnthagen/min-sized-rust
https://lifthrasiir.github.io/rustlog/why-is-a-rust-executable-large.html
https://github.com/RazrFalcon/cargo-bloat

@windelbouwman
Copy link
Contributor Author

Okay, I did some measurements.

rustpython commit: 9e194b3
Date: 2019-06-26
cargo version: 1.35.0
rustc version: 1.35.0
toolchain: stable-x86_64-unknown-linux-gnu
os: archlinux

First build in release mode:

cargo --release
target/release/rustpython = 11236832 bytes (11 MB)

Enable LTO (link time optimization) in Cargo.toml

# Cargo.toml
[profile.release]
lto = true

cargo --release
target/release/rustpython = 9387840 bytes (9 MB)

Run strip on the lto build:

target/release/rustpython = 7678664 bytes (7.6 MB)

@coolreader18
Copy link
Member

Oh wow, that's a lot better!

@pwnorbitals
Copy link

Probably this issue can be closed now ;) @windelbouwman

@youknowone
Copy link
Member

For now,

  • linux: 11MB
  • macos: 14MB
  • windows: 16MB

@lastmjs
Copy link

lastmjs commented Apr 25, 2023

The size is still too large for our use case, I suppose we can continue the discussion in this issue: #4203

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

No branches or pull requests

6 participants