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

Consider setting CARGO_INCREMENTAL=0 #26

Closed
dtolnay opened this issue Jul 19, 2022 · 2 comments · Fixed by #27
Closed

Consider setting CARGO_INCREMENTAL=0 #26

dtolnay opened this issue Jul 19, 2022 · 2 comments · Fixed by #27

Comments

@dtolnay
Copy link
Owner

dtolnay commented Jul 19, 2022

Judging by https://perf.rust-lang.org, from-scratch builds with incremental compilation enabled adds about 15–20% overhead compared to disabled. The initial build needs to write out more intermediate state in order for later incremental builds to take advantage of it.

In a CI situation, it would be extremely unusual for there to be a later incremental build within the same job. The jobs are not making changes to source code and rebuilding.

However, workflows that cache the target directory across runs might be benefiting from incremental compilation.

@CAD97
Copy link

CAD97 commented Jul 20, 2022

Generally the considered best-practice is to not cache local crate's artifacts in target, as the benefit of incremental for local changes is generally outweighed either by

  • using the first build with the cache key, thus an increasingly drifting out-of-date base, or
  • trashing and repopulating the cache on every run (GitHub workflow caching doesn't allow this).
  • Plus also just generally the cost of having a larger cache.

Swatinem/rust-cache is the current recommended cache action, which handles properly optimizing cache effectiveness for a cargo build in CI. That action also automatically sets CARGO_INCREMENTAL=0 for users of the action.

@dtolnay
Copy link
Owner Author

dtolnay commented Jul 20, 2022

Great information — thank you for weighing in.

Repository owner locked and limited conversation to collaborators Jan 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants