Skip to content

monolithic lto link time very slow when building with several codegen units #48025

Closed
@matthiaskrgr

Description

@matthiaskrgr

I noticed my project https://github.com/matthiaskrgr/cargo-cache took noticeably longer to build with "lto=true" at some point.
I benchmarked link time (touch src/main.rs; cargo build --release) which appear to blow up as soon as we have several codegen units.

link times:

release stable: 1.23 beta: 1.24 nightly: 1.25
profile.release, lto=true, codegen-units=1 45s 65s 48s
profile.release, lto=true 46s 278s 244s
profile.release (default) 6.3s 6.39 6.43s

So it seem codegen-units=1 makes for bad parallelism while building but speeds up lto because less translation units need to be merged.

Maybe it is possible to dynamically use as little codegen units as possible (but still enough to utilize all cores) when building? //cc #46910

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: An issue proposing an enhancement or a PR with one.I-compiletimeIssue: Problems and improvements with respect to compile times.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions