build: use ThinLTO for release binaries#23710
Merged
Merged
Conversation
64a4717 to
b1f2a98
Compare
|
would be interesting to see a comparison of max RAM use during compilation and some kind of runtime cpu load comparison between resulting binaries. |
b1f2a98 to
0f79266
Compare
anp-oai
added a commit
that referenced
this pull request
Jun 3, 2026
## Why PR descriptions can be visible outside the context used to generate them. In #23710, a generated description referenced an internal document, showing that the skill needs an explicit guardrail against exposing confidential context. ## What changed - Updated the `codex-pr-body` guidance to prohibit confidential references, including codenames and OpenAI-internal URLs.
bolinfest
reviewed
Jun 4, 2026
bolinfest
approved these changes
Jun 4, 2026
Collaborator
bolinfest
left a comment
There was a problem hiding this comment.
Approving assuming this changes to lto = "thin" as discussed in Slack, as it's a more conservative change an the opt level we are currently using in our alphas.
0f79266 to
ca53c6c
Compare
Collaborator
Author
|
Switched to ThinLTO per slack discussion, waiting for CI before merging |
After running a variety of Linux release builds of the CLI binary[0] it seems that this configuration is a good sweet spot when trading off between runtime performance, binary size, and build times. From git history it seems that using LTO was originally motivated by binary size reductions (see linked gist) but we can get much smaller binaries with much faster links if we switch from the default release optimization to asking LLVM to optimize aggressively for size. If our only priorities were build times and binary size, switching from opt-level 3 to z without any LTO might be the sweet spot since it's quite fast to build (again see linked gist). However ThinLTO is quite fast to build and leaves less performance on the table. Locally this cuts the time to build a release binary by 2/3 and the resulting binary is quite usable. [0] https://gist.github.com/anp/71820f253d4528f313171a57b3b895e7
Follow-up runtime measurements showed that optimizing globally for size significantly slows the final executable image path. Keep Cargo's default release opt-level of 3 and use ThinLTO for a lower-risk release build-time improvement that preserves cross-crate optimization.
ca53c6c to
1a6c84a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Fat LTO makes release builds substantially slower without providing enough measured runtime benefit to justify the release CI long pole. The build-profile investigation found that keeping Cargo's default release
opt-level=3and switching from fat LTO to ThinLTO (3/thin/1) reduced a cleancodex-clirelease build from 2073.893 seconds to 1243.172 seconds, a 40.06% improvement.The resulting binary increased from 196.7 MiB to 211.8 MiB (+7.63%). Measured runtime changes were small: the worst image workload median was +0.86% and app-server startup was +0.31% relative to fat LTO. ThinLTO retains cross-crate optimization while avoiding most of the fat-LTO build cost.
This deliberately avoids global size optimization: final-executable testing showed a substantial regression on the image request path, which is expected to become more important as image usage grows.
What changed
lto = "thin", retaining Cargo's default releaseopt-level=3.Validation
cargo metadata --no-deps --format-version 1.