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

Don't optimize for size. #3711

Merged
merged 1 commit into from
Aug 12, 2024
Merged

Conversation

jellefoks
Copy link
Member

This turns of the compiler flag for optimizing for size, so that it's optimizing for speed instead.

b/348717754

@jellefoks jellefoks requested a review from a team as a code owner June 27, 2024 22:02
@y4vor y4vor requested a review from hlwarriner June 28, 2024 14:11
@y4vor
Copy link
Contributor

y4vor commented Jun 28, 2024

What is the impact on the Evergreen binary size?

@hlwarriner
Copy link
Contributor

What is the impact on the Evergreen binary size?

This change shouldn't impact Evergreen, as for Evergreen the condition results in false both before and after this change.

Actually, I think that by default Evergreen targets are getting compiled with -O2.

Cobalt intends to optimize for size by default, and I believe that's why //starboard/build/config:size is added to default_compiler_configs: https://github.com/youtube/cobalt/blob/main/starboard/build/config/BUILDCONFIG.gn#L164. For Evergreen, this adds the -Os flag.

But default_compiler_configs also adds //build/config/compiler:default_optimization: https://github.com/youtube/cobalt/blob/main/starboard/build/config/BUILDCONFIG.gn#L170. And because optimize_for_size is false for Evergreen, this ends up adding -O2 (instead of -Oz) later in the compilation line: https://github.com/youtube/cobalt/blob/main/build/config/compiler/BUILD.gn#L2267.

Anyway, this may be a bug/regression and opportunity to reduce the size of the Evergreen binaries. Let's have a separate conversation about whether we want the target default to be -Os or -Oz for Evergreen. But I think this PR itself is ok from the Evergreen perspective.

@hlwarriner
Copy link
Contributor

What is the impact on the Evergreen binary size?

This change shouldn't impact Evergreen, as for Evergreen the condition results in false both before and after this change.

Actually, I think that by default Evergreen targets are getting compiled with -O2.

Cobalt intends to optimize for size by default, and I believe that's why //starboard/build/config:size is added to default_compiler_configs: https://github.com/youtube/cobalt/blob/main/starboard/build/config/BUILDCONFIG.gn#L164. For Evergreen, this adds the -Os flag.

But default_compiler_configs also adds //build/config/compiler:default_optimization: https://github.com/youtube/cobalt/blob/main/starboard/build/config/BUILDCONFIG.gn#L170. And because optimize_for_size is false for Evergreen, this ends up adding -O2 (instead of -Oz) later in the compilation line: https://github.com/youtube/cobalt/blob/main/build/config/compiler/BUILD.gn#L2267.

Anyway, this may be a bug/regression and opportunity to reduce the size of the Evergreen binaries. Let's have a separate conversation about whether we want the target default to be -Os or -Oz for Evergreen. But I think this PR itself is ok from the Evergreen perspective.

The Evergreen issue does look like a regression from the Base/Net updates. #2969 made the change, and b/330781200 is also relevant.

Copy link
Member

@kaidokert kaidokert left a comment

Choose a reason for hiding this comment

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

Please rebase just in case

This turns of the compiler flag for optimizing for size, so that it's
optimizing for speed instead.

b/348717754
@jellefoks
Copy link
Member Author

Please rebase just in case

Force pushed to rebase and rerun actions (GitHub UI didn't show a rebase button).

@jellefoks jellefoks merged commit bf3a4c4 into youtube:main Aug 12, 2024
317 of 318 checks passed
@jellefoks jellefoks added the cp-25.lts.1+ Cherry Pick to the 25.lts.1+ branch label Aug 12, 2024
cobalt-github-releaser-bot pushed a commit that referenced this pull request Aug 12, 2024
This turns of the compiler flag for optimizing for size, so that it's
optimizing for speed instead.

b/348717754

(cherry picked from commit bf3a4c4)
jellefoks added a commit that referenced this pull request Aug 13, 2024
Refer to the original PR: #3711

This turns of the compiler flag for optimizing for size, so that it's
optimizing for speed instead.

b/348717754

Co-authored-by: Jelle Foks <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cp-25.lts.1+ Cherry Pick to the 25.lts.1+ branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants