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

build: reduce binary size #4437

Merged
merged 2 commits into from
Oct 31, 2024
Merged

Conversation

Jayllyz
Copy link
Contributor

@Jayllyz Jayllyz commented Oct 31, 2024

Summary

Biome recently reached 5M downloads! However, with the current npm binary size of 29MB (v1.9.4), this translates to 100TB+ of cumulative download data. This PR aims to optimize the binary size to reduce bandwidth usage.

Binary size optimization results (tested on commit 3401663):

  • Before: 32.9MB (only lto)
  • After: 30.45MB (codegen-units=1)

All options are explained here : https://doc.rust-lang.org/cargo/reference/profiles.html

  • Set codegen-units = 1: Can reduces binary size and improves runtime performance

Test Plan

Tested on Sentry repo like ecosystem-ci (6164 files)

@ematipico
Copy link
Member

ematipico commented Oct 31, 2024

Actually, we already set some of those flags in the CI.

# Strip all debug symbols from the resulting binaries
RUSTFLAGS: "-C strip=symbols"

The reason why they aren't set in Cargo.toml is that we want to create a local release as fast as possible.

So you might want to redirect those new flags in the CI job instead. What do you think?

@Jayllyz
Copy link
Contributor Author

Jayllyz commented Oct 31, 2024

In fact, we've already defined some of these flags in the CI.

My bad, haven't checked the CI files...
I'll add the codegen unit flags here then.

Copy link
Contributor

@arendjr arendjr left a comment

Choose a reason for hiding this comment

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

Do you know what the impact is with only the codegen unit change?

@Jayllyz
Copy link
Contributor Author

Jayllyz commented Oct 31, 2024

Do you know what the impact is with only the codegen unit change?

30.45MB
with this config

[profile.release]
codegen-units = 1
lto           = true

@ematipico ematipico merged commit b02d6c9 into biomejs:main Oct 31, 2024
4 checks passed
@Jayllyz Jayllyz deleted the build/reduce-binary-size branch October 31, 2024 11:02
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.

3 participants