Consider "codegen-units = 1" optimization for the Release profile in Codex Rust

Resolved 💬 1 comment Opened Jun 28, 2025 by zamazan4ik Closed Jun 28, 2025

Hi!

I see that the project already uses FatLTO in the Release profile. Additionally, I suggest enabling the codegen-units = 1(CG1) optimization too. Enabling more advanced optimizations allows us to reduce the binary size further (always a good thing) and improve the application performance even more. Especially since you care about the binary size.

Basically, it can be enabled with the following change:

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

I have made quick local tests (AMD Ryzen 9 5900x, Fedora 42, Rust 1.88, the latest version of this project at the moment, cargo build --release --all-features --all-targets command from the CI script) - the results are below.

| Build config \ Binary name | codex | codex-tui | codex-exec | codex-execpolicy | codex-file-search | codex-linux-sandbox | codex-mcp-client | codex-mcp-server |
|---|---|---|---|---|---|---|---|---|
| FatLTO | 17 Mib | 15 Mib | 11 Mib | 7.7 Mib | 3 Mib | 870 Kib | 3.6 Mib | 8.1 Mib |
| FatLTO + CG1 | 16 Mib | 14 Mib | 9.5 Mib | 6.8 Mib | 2.9 Mib | 828 Kib | 3.3 Mib | 7.6 Mib |

Clean build time was even reduced from 2m 45s to 2m 15s.

Thank you.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗