Skip to content

Add more optimizations to the release build profile. #11298

Open
@horacehoff

Description

@horacehoff

Problem

The release profile is used when wanting to build an optimized binary. Thus, I think it would be logical to optimize it to the fullest, sometimes at the cost of a greater build time, but I think it is a good compromise for many people, including me.

Proposed Solution

More optimizations flags should be added to the release build profile, notably lto=true and codegen-units=1, as well as optimizing all the packages with opt-level=3.
This greatly enhances runtime performance, although yes, at the cost of a bigger binary size and longer build time.

Notes

I have tested what I am proposing, with the following added in my cargo.toml:

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

[profile.release.package."*"]
opt-level = 3

This improved the output binary's runtime performance by orders of magnitude, thus this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-profilesArea: profilesC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`S-triageStatus: This issue is waiting on initial triage.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions