Introduce a minimum CGU size in non-incremental builds.
Because tiny CGUs make compilation less efficient *and* result in worse generated code. We don't do this when the number of CGUs is explicitly given, because there are times when the requested number is very important, as described in some comments within the commit. So the commit also introduces a `CodegenUnits` type that distinguishes between default values and user-specified values. This change has a roughly neutral effect on walltimes across the rustc-perf benchmarks; there are some speedups and some slowdowns. But it has significant wins for most other metrics on numerous benchmarks, including instruction counts, cycles, binary size, and max-rss. It also reduces parallelism, which is good for reducing jobserver competition when multiple rustc processes are running at the same time. It's smaller benchmarks that benefit the most; larger benchmarks already have CGUs that are all larger than the minimum size. Here are some example before/after CGU sizes for opt builds. - html5ever - CGUs: 16, mean size: 1196.1, sizes: [3908, 2992, 1706, 1652, 1572, 1136, 1045, 948, 946, 938, 579, 471, 443, 327, 286, 189] - CGUs: 4, mean size: 4396.0, sizes: [6706, 3908, 3490, 3480] - libc - CGUs: 12, mean size: 35.3, sizes: [163, 93, 58, 53, 37, 8, 2 (x6)] - CGUs: 1, mean size: 424.0, sizes: [424] - tt-muncher - CGUs: 5, mean size: 1819.4, sizes: [8508, 350, 198, 34, 7] - CGUs: 1, mean size: 9075.0, sizes: [9075] Note that CGUs of size 100,000+ aren't unusual in larger programs.
This commit is contained in:
parent
95d85899ce
commit
7c3ce02a11
5 changed files with 65 additions and 18 deletions
|
@ -1385,7 +1385,7 @@ fn vcall_visibility_metadata<'ll, 'tcx>(
|
|||
let trait_def_id = trait_ref_self.def_id();
|
||||
let trait_vis = cx.tcx.visibility(trait_def_id);
|
||||
|
||||
let cgus = cx.sess().codegen_units();
|
||||
let cgus = cx.sess().codegen_units().as_usize();
|
||||
let single_cgu = cgus == 1;
|
||||
|
||||
let lto = cx.sess().lto();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue