rust/compiler/rustc_codegen_llvm/src
Nicholas Nethercote 7c3ce02a11 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.
2023-06-14 10:57:44 +10:00
..
back use new c literals instead of cstr! macro 2023-05-31 19:40:24 +03:00
coverageinfo Use Option::is_some_and and Result::is_ok_and in the compiler 2023-05-24 14:20:41 +00:00
debuginfo Introduce a minimum CGU size in non-incremental builds. 2023-06-14 10:57:44 +10:00
llvm Add SafeStack support to rustc 2023-05-26 15:18:54 -04:00
abi.rs Remove double spaces after dots in comments 2023-01-17 08:09:33 +00:00
allocator.rs use new c literals instead of cstr! macro 2023-05-31 19:40:24 +03:00
asm.rs Rollup merge of #111332 - loongarch-rs:inline-asm, r=Amanieu 2023-05-08 19:41:51 +09:00
attributes.rs Add SafeStack support to rustc 2023-05-26 15:18:54 -04:00
base.rs use new c literals instead of cstr! macro 2023-05-31 19:40:24 +03:00
builder.rs Rollup merge of #111647 - klensy:cstr, r=oli-obk 2023-06-02 18:12:45 +02:00
callee.rs CFI: Fix SIGILL reached via trait objects 2023-05-09 20:04:19 +00:00
common.rs Stop creating intermediate places just to immediate convert them to operands 2023-05-26 15:01:29 +00:00
consts.rs Rollup merge of #111647 - klensy:cstr, r=oli-obk 2023-06-02 18:12:45 +02:00
context.rs Rollup merge of #111647 - klensy:cstr, r=oli-obk 2023-06-02 18:12:45 +02:00
declare.rs CFI: Fix SIGILL reached via trait objects 2023-05-09 20:04:19 +00:00
errors.rs Use translatable diagnostics in rustc_const_eval 2023-06-01 14:45:18 +00:00
intrinsic.rs CFI: Fix SIGILL reached via trait objects 2023-05-09 20:04:19 +00:00
lib.rs Removed use of iteration through a HashMap/HashSet in rustc_incremental and replaced with IndexMap/IndexSet 2023-06-04 21:54:28 -04:00
llvm_util.rs Create a structure to define the features from to_llvm_features. 2023-05-22 14:46:40 +01:00
mono_item.rs Use is_some_and/is_ok_and in less obvious spots 2023-05-24 14:33:43 +00:00
type_.rs Use load-store instead of memcpy for short integer arrays 2023-06-04 00:51:49 -07:00
type_of.rs Use load-store instead of memcpy for short integer arrays 2023-06-04 00:51:49 -07:00
va_arg.rs Implement va_list and va_arg for s390x FFI 2022-12-19 21:07:57 +01:00
value.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00