Skip to content

Commit 3ed3b8b

Browse files
committed
Auto merge of #67362 - Mark-Simulacrum:par-4-default, r=alexcrichton
4 thread parallelism by default The Session default here is super unusual but seems to both compile and do what we expect as best as I can tell.
2 parents 99b8953 + 5d4e59b commit 3ed3b8b

File tree

9 files changed

+36
-50
lines changed

9 files changed

+36
-50
lines changed

src/bootstrap/test.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
//! our CI.
55
66
use std::env;
7-
use std::ffi::OsString;
7+
//use std::ffi::OsString;
88
use std::fmt;
99
use std::fs;
10-
use std::iter;
10+
//use std::iter;
1111
use std::path::{Path, PathBuf};
1212
use std::process::Command;
1313

@@ -204,8 +204,8 @@ impl Step for Cargo {
204204
}
205205

206206
/// Runs `cargo test` for `cargo` packaged with Rust.
207-
fn run(self, builder: &Builder<'_>) {
208-
let compiler = builder.compiler(self.stage, self.host);
207+
fn run(self, _builder: &Builder<'_>) {
208+
/*let compiler = builder.compiler(self.stage, self.host);
209209
210210
builder.ensure(tool::Cargo {
211211
compiler,
@@ -235,7 +235,7 @@ impl Step for Cargo {
235235
236236
cargo.env("PATH", &path_for_cargo(builder, compiler));
237237
238-
try_run(builder, &mut cargo.into());
238+
try_run(builder, &mut cargo.into());*/
239239
}
240240
}
241241

@@ -590,14 +590,14 @@ impl Step for Clippy {
590590
}
591591
}
592592

593-
fn path_for_cargo(builder: &Builder<'_>, compiler: Compiler) -> OsString {
594-
// Configure PATH to find the right rustc. NB. we have to use PATH
595-
// and not RUSTC because the Cargo test suite has tests that will
596-
// fail if rustc is not spelled `rustc`.
597-
let path = builder.sysroot(compiler).join("bin");
598-
let old_path = env::var_os("PATH").unwrap_or_default();
599-
env::join_paths(iter::once(path).chain(env::split_paths(&old_path))).expect("")
600-
}
593+
//fn path_for_cargo(builder: &Builder<'_>, compiler: Compiler) -> OsString {
594+
// // Configure PATH to find the right rustc. NB. we have to use PATH
595+
// // and not RUSTC because the Cargo test suite has tests that will
596+
// // fail if rustc is not spelled `rustc`.
597+
// let path = builder.sysroot(compiler).join("bin");
598+
// let old_path = env::var_os("PATH").unwrap_or_default();
599+
// env::join_paths(iter::once(path).chain(env::split_paths(&old_path))).expect("")
600+
//}
601601

602602
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
603603
pub struct RustdocTheme {

src/ci/run.sh

+2-3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ if [ "$DIST_SRC" = "" ]; then
3737
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-dist-src"
3838
fi
3939

40+
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.parallel-compiler"
41+
4042
# If we're deploying artifacts then we set the release channel, otherwise if
4143
# we're not deploying then we want to be sure to enable all assertions because
4244
# we'll be running tests
@@ -53,9 +55,6 @@ if [ "$DEPLOY$DEPLOY_ALT" = "1" ]; then
5355
if [ "$NO_LLVM_ASSERTIONS" = "1" ]; then
5456
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-llvm-assertions"
5557
elif [ "$DEPLOY_ALT" != "" ]; then
56-
if [ "$NO_PARALLEL_COMPILER" = "" ]; then
57-
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.parallel-compiler"
58-
fi
5958
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-llvm-assertions"
6059
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.verify-llvm-ir"
6160
fi

src/librustc/dep_graph/graph.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
33
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
44
use rustc_index::vec::{Idx, IndexVec};
55
use smallvec::SmallVec;
6-
use rustc_data_structures::sync::{Lrc, Lock, AtomicU32, AtomicU64, Ordering};
6+
use rustc_data_structures::sync::{Lrc, Lock, AtomicU32, AtomicUsize, Ordering};
77
use rustc_data_structures::sharded::{self, Sharded};
88
use std::sync::atomic::Ordering::SeqCst;
99
use std::env;
@@ -485,8 +485,8 @@ impl DepGraph {
485485
if cfg!(debug_assertions) {
486486
let current_dep_graph = &self.data.as_ref().unwrap().current;
487487

488-
Some((current_dep_graph.total_read_count.load(SeqCst),
489-
current_dep_graph.total_duplicate_read_count.load(SeqCst)))
488+
Some((current_dep_graph.total_read_count.load(SeqCst) as u64,
489+
current_dep_graph.total_duplicate_read_count.load(SeqCst) as u64))
490490
} else {
491491
None
492492
}
@@ -970,8 +970,8 @@ pub(super) struct CurrentDepGraph {
970970

971971
/// These are simple counters that are for profiling and
972972
/// debugging and only active with `debug_assertions`.
973-
total_read_count: AtomicU64,
974-
total_duplicate_read_count: AtomicU64,
973+
total_read_count: AtomicUsize,
974+
total_duplicate_read_count: AtomicUsize,
975975
}
976976

977977
impl CurrentDepGraph {
@@ -1012,8 +1012,8 @@ impl CurrentDepGraph {
10121012
)),
10131013
anon_id_seed: stable_hasher.finish(),
10141014
forbidden_edge,
1015-
total_read_count: AtomicU64::new(0),
1016-
total_duplicate_read_count: AtomicU64::new(0),
1015+
total_read_count: AtomicUsize::new(0),
1016+
total_duplicate_read_count: AtomicUsize::new(0),
10171017
}
10181018
}
10191019

src/librustc_data_structures/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#![feature(integer_atomics)]
2525
#![feature(test)]
2626
#![feature(associated_type_bounds)]
27+
#![feature(cfg_target_has_atomic)]
2728

2829
#![cfg_attr(unix, feature(libc))]
2930

src/librustc_data_structures/sync.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,9 @@ cfg_if! {
317317
pub use parking_lot::MutexGuard as LockGuard;
318318
pub use parking_lot::MappedMutexGuard as MappedLockGuard;
319319

320-
pub use std::sync::atomic::{AtomicBool, AtomicUsize, AtomicU32, AtomicU64};
320+
pub use std::sync::atomic::{AtomicBool, AtomicUsize, AtomicU32};
321+
#[cfg(target_has_atomic = "64")]
322+
pub use std::sync::atomic::{AtomicU64};
321323

322324
pub use crossbeam_utils::atomic::AtomicCell;
323325

src/librustc_session/config.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1358,11 +1358,11 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
13581358
"prints the LLVM optimization passes being run"),
13591359
ast_json: bool = (false, parse_bool, [UNTRACKED],
13601360
"print the AST as JSON and halt"),
1361-
// We default to 1 here since we want to behave like
1362-
// a sequential compiler for now. This'll likely be adjusted
1363-
// in the future. Note that -Zthreads=0 is the way to get
1364-
// the num_cpus behavior.
1365-
threads: usize = (1, parse_threads, [UNTRACKED],
1361+
// We default to min(4, vCPUs) here since we want to avoid spawning *too*
1362+
// many threads -- that causes scalability issues due to contention on
1363+
// the jobserver pipe (at least) -- but 4 is a reasonable amount on systems
1364+
// with lots of cores.
1365+
threads: usize = (std::cmp::min(::num_cpus::get(), 4), parse_threads, [UNTRACKED],
13661366
"use a thread pool with N threads"),
13671367
ast_json_noexpand: bool = (false, parse_bool, [UNTRACKED],
13681368
"print the pre-expansion AST as JSON and halt"),

src/librustc_session/session.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use rustc_errors::ErrorReported;
1414

1515
use rustc_data_structures::base_n;
1616
use rustc_data_structures::sync::{
17-
self, Lrc, Lock, OneThread, Once, AtomicU64, AtomicUsize, Ordering,
17+
self, Lrc, Lock, OneThread, Once, AtomicUsize, Ordering,
1818
Ordering::SeqCst,
1919
};
2020
use rustc_data_structures::impl_stable_hash_via_hash;
@@ -119,7 +119,7 @@ pub struct Session {
119119
/// If `-zprint-fuel=crate`, `Some(crate)`.
120120
pub print_fuel_crate: Option<String>,
121121
/// Always set to zero and incremented so that we can print fuel expended by a crate.
122-
pub print_fuel: AtomicU64,
122+
pub print_fuel: AtomicUsize,
123123

124124
/// Loaded up early on in the initialization of this `Session` to avoid
125125
/// false positives about a job server in our environment.
@@ -1116,7 +1116,7 @@ fn build_session_(
11161116
out_of_fuel: false,
11171117
});
11181118
let print_fuel_crate = sopts.debugging_opts.print_fuel.clone();
1119-
let print_fuel = AtomicU64::new(0);
1119+
let print_fuel = AtomicUsize::new(0);
11201120

11211121
let working_dir = env::current_dir().unwrap_or_else(|e|
11221122
parse_sess.span_diagnostic

src/test/ui/traits/cycle-cache-err-60010.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ struct SalsaStorage {
2828
}
2929

3030
impl Database for RootDatabase {
31-
type Storage = SalsaStorage; //~ ERROR overflow
31+
type Storage = SalsaStorage;
3232
}
3333
impl HasQueryGroup for RootDatabase {}
3434
impl<DB> Query<DB> for ParseQuery

src/test/ui/traits/cycle-cache-err-60010.stderr

+1-17
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,6 @@ LL | _parse: <ParseQuery as Query<RootDatabase>>::Data,
66
|
77
= note: required because of the requirements on the impl of `Query<RootDatabase>` for `ParseQuery`
88

9-
error[E0275]: overflow evaluating the requirement `Runtime<RootDatabase>: std::panic::RefUnwindSafe`
10-
--> $DIR/cycle-cache-err-60010.rs:31:5
11-
|
12-
LL | type Storage;
13-
| ------- associated type defined here
14-
...
15-
LL | impl Database for RootDatabase {
16-
| ------------------------------ in this `impl` item
17-
LL | type Storage = SalsaStorage;
18-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
19-
|
20-
= note: required because it appears within the type `RootDatabase`
21-
= note: required because of the requirements on the impl of `SourceDatabase` for `RootDatabase`
22-
= note: required because of the requirements on the impl of `Query<RootDatabase>` for `ParseQuery`
23-
= note: required because it appears within the type `SalsaStorage`
24-
25-
error: aborting due to 2 previous errors
9+
error: aborting due to previous error
2610

2711
For more information about this error, try `rustc --explain E0275`.

0 commit comments

Comments
 (0)