buildRustCrate: make default value for codegenUnits configurable#383716
buildRustCrate: make default value for codegenUnits configurable#383716Kranzes merged 1 commit intoNixOS:masterfrom
Conversation
c1e414a to
c862c3b
Compare
c862c3b to
091a959
Compare
There's already been a bit of a debate on what this should be set to, see #130309 (and follow the breadcrumbs from there). Also see https://discourse.nixos.org/t/crate2nix-setting-codegenunits-for-all-crates/53014/9 for some recent benchmarking. |
|
@flokli thank you for the feedback, but as I said, I'm not here to debate the default, but just want to make it easier to change the default for all crates at once |
I'm not entirely sure this is a great benchmark since it's just one crate which was hastily tested, and included still-experimental compiler flags |
Not objecting the PR, just providing additional context, especially on why it might be set to 1 currently. |
|
Also, fwiw, in our own monorepo, increasing codegen units to 16 decreased our cold build time from 9 to 7 minutes. |
As of now,
buildRustCratedefaults to using a single codegen unit per crate, which is far off from what cargo is doing:Before debating whether the value itself should be increased, we should at least make it easy to override this for all crates at once, by introducing a parameter
defaultCodegenUnits. In its current state, thecodegenUnitsparameter must be overriden per crate to increase codegen parallelization.Note that this change does not affect anything inside nixpkgs, but mainly consumers of crate2nix (also see #373744).
Example usage for crate2nix:
Things done
nix.conf? (See Nix manual)sandbox = relaxedsandbox = truenix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)Add a 👍 reaction to pull requests you find important.