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

chore: reduce realease binary size #1794

Merged
merged 2 commits into from
Nov 2, 2023
Merged

chore: reduce realease binary size #1794

merged 2 commits into from
Nov 2, 2023

Conversation

vaind
Copy link
Collaborator

@vaind vaind commented Nov 1, 2023

Sentry CLI is downloaded many times during consumers' CI. Even though the download should be fast in general and the binary size reduction wouldn't have a great effect on individual runs, it does have an effect at the scale it is used at.

Example: macOS arm64 binary size reduction by these changes is about 30 %.

@vaind vaind marked this pull request as ready for review November 2, 2023 08:42
@loewenheim
Copy link
Contributor

I've been experimenting along similar lines. In my test, for whatever reason, setting codegen-units to 1 actually slightly increased binary size, have you checked whether it has a positive effect?

Also, setting the opt level to "s" reduces the size significantly. It carries a performance hit, but that is likely negligible.

Copy link
Member

@Swatinem Swatinem left a comment

Choose a reason for hiding this comment

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

having only one CGU means that the compiler has more inlining opportunities, so probably generates more code.
however with CGU=1 and LTO, it should generate fewer duplicates as well.

@vaind
Copy link
Collaborator Author

vaind commented Nov 2, 2023

For me (arm64 macos) the build is smaller with CGU=1 by about 100 KiB.

Setting the opt-level to S reduces the size by further 2 MiB and going for Z means another MiB down.

@vaind vaind merged commit 40f86f6 into master Nov 2, 2023
34 of 38 checks passed
@vaind vaind deleted the chore/smaller-binary-size branch November 2, 2023 13:08
@vaind
Copy link
Collaborator Author

vaind commented Nov 14, 2023

For future reference, here's the size reduction for a release containing this PR (between 25 and 55 % size reduction):
image

szokeasaurusrex added a commit that referenced this pull request Dec 4, 2023
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