Skip to content

Commit e8379a7

Browse files
committed
XXX: more
1 parent aff730e commit e8379a7

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

compiler/rustc_codegen_ssa/src/base.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@ use rustc_span::symbol::sym;
3838
use rustc_span::Symbol;
3939
use rustc_target::abi::{Align, FIRST_VARIANT};
4040

41-
use std::cmp;
4241
use std::collections::BTreeSet;
4342
use std::time::{Duration, Instant};
4443

44+
use itertools::Itertools;
45+
4546
pub fn bin_op_to_icmp_predicate(op: hir::BinOpKind, signed: bool) -> IntPredicate {
4647
match op {
4748
hir::BinOpKind::Eq => IntPredicate::IntEQ,
@@ -673,8 +674,10 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
673674
// are large size variations, this can reduce memory usage significantly.
674675
let codegen_units: Vec<_> = {
675676
let mut sorted_cgus = codegen_units.iter().collect::<Vec<_>>();
676-
sorted_cgus.sort_by_cached_key(|cgu| cmp::Reverse(cgu.size_estimate()));
677-
sorted_cgus
677+
sorted_cgus.sort_by_cached_key(|cgu| cgu.size_estimate());
678+
679+
let (first_half, second_half) = sorted_cgus.split_at(sorted_cgus.len() / 2);
680+
second_half.iter().rev().interleave(first_half).copied().collect()
678681
};
679682

680683
// Calculate the CGU reuse

compiler/rustc_monomorphize/src/partitioning.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ fn merge_codegen_units<'tcx>(
313313
// worse generated code. So we don't allow CGUs smaller than this (unless
314314
// there is just one CGU, of course). Note that CGU sizes of 100,000+ are
315315
// common in larger programs, so this isn't all that large.
316-
const NON_INCR_MIN_CGU_SIZE: usize = 1500;
316+
const NON_INCR_MIN_CGU_SIZE: usize = 2000;
317317

318318
// Repeatedly merge the two smallest codegen units as long as:
319319
// - we have more CGUs than the upper limit, or
@@ -353,9 +353,10 @@ fn merge_codegen_units<'tcx>(
353353
// codegen_units[codegen_units.len() - 1].size_estimate());
354354

355355
(codegen_units[0].size_estimate() as f64 * 0.8)
356-
>= (codegen_units[codegen_units.len() - 2].size_estimate()
357-
+ codegen_units[codegen_units.len() - 1].size_estimate()) as f64
358-
};
356+
>= (codegen_units[codegen_units.len() - 2].size_estimate()
357+
+ codegen_units[codegen_units.len() - 1].size_estimate())
358+
as f64
359+
};
359360

360361
if !(merge1 || merge2 || merge3) {
361362
break;

0 commit comments

Comments
 (0)