Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Faster build upto 5x using defaults in Cargo.toml #10601

Closed
rrjanbiah opened this issue Apr 26, 2022 · 2 comments
Closed

Faster build upto 5x using defaults in Cargo.toml #10601

rrjanbiah opened this issue Apr 26, 2022 · 2 comments
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`

Comments

@rrjanbiah
Copy link

Problem

When https://github.com/dimensionhq/fleet claimed to be 5x faster than Cargo, vladvasiliu in HN mentioned some defaults that can be added in the Cargo.toml for the same performance improvement:

[build]
rustc-wrapper = "/usr/bin/sccache"
 
[target.x86_64-unknown-linux-gnu]
linker = "clang"
rustflags = ["-C", "link-arg=-fuse-ld=/usr/bin/mold"]

Proposed Solution

If that's true, please add above defaults in Cargo.toml

Notes

No response

@rrjanbiah rrjanbiah added the C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` label Apr 26, 2022
@weihanglo
Copy link
Member

weihanglo commented Apr 26, 2022

Thanks. It's interesting. Glad to see people innovating new tools around Cargo to improve the ecosystem. That's why Cargo thrives on being configurable.

Unfortunately, it is often not easy to change the defaults. We usually do benchmarks with as much real world cases as we could. For example, people working on compiler performance this year try to benchmark different profile settings. Even with a great improvement of the initial result, there are still some cases might get performance loss, let alone some configs might make debugging proc-macro/build script harder.

Back to the configurations you proposed. sccache is a great tool to share compilation cache across packages. It's easy to install and use even without being default. However, it might break someone's code if Cargo switches wrapper to sccache. sccache itself does not support incremental compilation at this moment. From my personal experience, sccache does not always speedup the build. Leaving the option for users to choose might be a better default.

For mold, it's quite astonishing. I use it on my personal project. However, it is not prevalent in Linux world and people need to install it additionally. Here is a discussion about default linker you might be interested in.

Generally, Cargo tries its best to provide a configurable build settings. When talking about changing defaults, it is often conservative in order not to break people's code.

There is a group of great developers working on compiler performance. Its roadmap covers parts of the proposed defaults. I am going to close this issue and leave the stage for them. If you think they are different, feel free to reopen.

@epage
Copy link
Contributor

epage commented Apr 26, 2022

For more on why it can't be adopted as-is, see this break down of what fleet does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
Projects
None yet
Development

No branches or pull requests

3 participants