8000 Consider enabling more aggressive optimizations for the Dist profile: Fat LTO and codegen-units = 1 · Issue #88 · ynqa/jnv · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Consider enabling more aggressive optimizations for the Dist profile: Fat LTO and codegen-units = 1 #88
Open
@zamazan4ik

Description

@zamazan4ik

Hi!

I see that the project already uses ThinLTO in the Dist profile in the root Cargo.toml file. However, ThinLTO is usually less efficient from the perspective of performed optimizations than Fat (aka Full) LTO, and cargo-dist defaults are not the most optimal by default. Additionally, I suggest enabling codegen-units = 1 (CG1) too. Enabling more advanced optimizations allows us to reduce the binary size further (always a good thing) and improve the application performance more.

Basically, it can be enabled with the following change:

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

I have made quick local tests (AMD Ryzen 5900x, Fedora 41, Rust 1.85.1, the latest version of this project at the moment, cargo build --profile dist command) - the results are below.

  • ThinLTO (current Dist profile): 9.5 Mib, clean build time: 22s
  • ThinLTO + codegen-units = 1: 7.4 Mib, clean build time: 38s
  • FatLTO: 7.3 Mib, clean build time: 46s
  • FatLTO + codegen-units = 1: 6.8 Mib, clean build time: 57s

I didn't perform performance benchmarks but FatLTO + CG1 should be the most optimized version too.

Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0