Skip to content

Commit b5a6178

Browse files
committed
Use item count to estimate CGU size.
1 parent 1065d87 commit b5a6178

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

Diff for: compiler/rustc_middle/src/mir/mono.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,13 @@ impl<'tcx> MonoItem<'tcx> {
5656
}
5757
}
5858

59-
pub fn size_estimate(&self, tcx: TyCtxt<'tcx>) -> usize {
59+
pub fn size_estimate(&self, _tcx: TyCtxt<'tcx>) -> usize {
6060
match *self {
61-
MonoItem::Fn(instance) => {
61+
MonoItem::Fn(_instance) => {
6262
// Estimate the size of a function based on how many statements
6363
// it contains.
64-
tcx.instance_def_size_estimate(instance.def)
64+
//tcx.instance_def_size_estimate(instance.def)
65+
1
6566
}
6667
// Conservatively estimate the size of a static declaration
6768
// or assembly to be 1.
@@ -321,8 +322,7 @@ impl<'tcx> CodegenUnit<'tcx> {
321322
}
322323

323324
pub fn compute_size_estimate(&mut self, tcx: TyCtxt<'tcx>) {
324-
// Estimate the size of a codegen unit as (approximately) the number of MIR
325-
// statements it corresponds to.
325+
// Estimate the size of a codegen unit as the number of items in it.
326326
self.size_estimate = self.items.keys().map(|mi| mi.size_estimate(tcx)).sum();
327327
}
328328

Diff for: compiler/rustc_monomorphize/src/partitioning.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -328,9 +328,9 @@ fn merge_codegen_units<'tcx>(
328328
// Having multiple CGUs can drastically speed up compilation. But for
329329
// non-incremental builds, tiny CGUs slow down compilation *and* result in
330330
// worse generated code. So we don't allow CGUs smaller than this (unless
331-
// there is just one CGU, of course). Note that CGU sizes of 100,000+ are
331+
// there is just one CGU, of course). Note that CGU sizes of 3,000+ are
332332
// common in larger programs, so this isn't all that large.
333-
const NON_INCR_MIN_CGU_SIZE: usize = 1800;
333+
const NON_INCR_MIN_CGU_SIZE: usize = 65;
334334

335335
// Repeatedly merge the two smallest codegen units as long as:
336336
// - we have more CGUs than the upper limit, or

0 commit comments

Comments
 (0)