Skip to content

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

Closed

Description

@zamazan4ik

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.

Activity

  1. bolinfest commented on Jun 28, 2025

    @bolinfest
    Collaborator

    @zamazan4ik Thanks for the detailed suggestion with all the references! Just added this in #1421.

  2. added a commit that references this issue on Apr 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions