Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit e31e69b

Browse files
committed
Auto merge of rust-lang#129222 - saethlin:more-incr-cgus, r=<try>
Use more CGUs in incremental compilation Just wondering how this looks in perf... r? `@ghost`
2 parents d571ae8 + f5425e2 commit e31e69b

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

compiler/rustc_monomorphize/src/partitioning.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,14 @@ fn compute_codegen_unit_name(
691691
let mut cgu_def_id = None;
692692
// Walk backwards from the item we want to find the module for.
693693
loop {
694+
if tcx.sess.opts.incremental.is_some()
695+
&& tcx.sess.opts.optimize == rustc_session::config::OptLevel::No
696+
&& def_id.is_local()
697+
{
698+
cgu_def_id = Some(current_def_id);
699+
break;
700+
}
701+
694702
if current_def_id.is_crate_root() {
695703
if cgu_def_id.is_none() {
696704
// If we have not found a module yet, take the crate root.
@@ -717,8 +725,7 @@ fn compute_codegen_unit_name(
717725
let def_path = tcx.def_path(cgu_def_id);
718726

719727
let components = def_path.data.iter().map(|part| match part.data.name() {
720-
DefPathDataName::Named(name) => name,
721-
DefPathDataName::Anon { .. } => unreachable!(),
728+
DefPathDataName::Named(name) | DefPathDataName::Anon { namespace: name } => name,
722729
});
723730

724731
let volatile_suffix = volatile.then_some("volatile");

compiler/rustc_session/src/session.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,7 @@ impl Session {
830830
// codegen units in order to reduce the "collateral damage" small
831831
// changes cause.
832832
if self.opts.incremental.is_some() {
833-
return CodegenUnits::Default(256);
833+
return CodegenUnits::Default(4096);
834834
}
835835

836836
// Why is 16 codegen units the default all the time?

0 commit comments

Comments
 (0)