]> git.lizzy.rs Git - rust.git/commit
rustc: Default 32 codegen units at O0
authorAlex Crichton <alex@alexcrichton.com>
Mon, 25 Sep 2017 19:26:25 +0000 (12:26 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Tue, 26 Sep 2017 15:18:03 +0000 (08:18 -0700)
commit9e35b797b158d2e437bfee6376f852fd87861286
tree991f5c67e13dffe9fa45e6491c27a84c1dbbb724
parent4b8bf391fd595ac0c1ff6e6b7f1ef57cec4eb6da
rustc: Default 32 codegen units at O0

This commit changes the default of rustc to use 32 codegen units when compiling
in debug mode, typically an opt-level=0 compilation. Since their inception
codegen units have matured quite a bit, gaining features such as:

* Parallel translation and codegen enabling codegen units to get worked on even
  more quickly.
* Deterministic and reliable partitioning through the same infrastructure as
  incremental compilation.
* Global rate limiting through the `jobserver` crate to avoid overloading the
  system.

The largest benefit of codegen units has forever been faster compilation through
parallel processing of modules on the LLVM side of things, using all the cores
available on build machines that typically have many available. Some downsides
have been fixed through the features above, but the major downside remaining is
that using codegen units reduces opportunities for inlining and optimization.
This, however, doesn't matter much during debug builds!

In this commit the default number of codegen units for debug builds has been
raised from 1 to 32. This should enable most `cargo build` compiles that are
bottlenecked on translation and/or code generation to immediately see speedups
through parallelization on available cores.

Work is being done to *always* enable multiple codegen units (and therefore
parallel codegen) but it requires #44841 at least to be landed and stabilized,
but stay tuned if you're interested in that aspect!
src/librustc/session/config.rs
src/librustc_trans/back/link.rs
src/librustc_trans/back/write.rs
src/librustc_trans/base.rs
src/test/run-make/codegen-options-parsing/Makefile
src/test/run-make/llvm-phase/test.rs