about summary refs log tree commit diff
path: root/src/librustc_interface
diff options
context:
space:
mode:
authorMark Rousskov <mark.simulacrum@gmail.com>2019-09-30 16:27:28 -0400
committerMark Rousskov <mark.simulacrum@gmail.com>2019-09-30 16:49:19 -0400
commit1a1067d1a537d6495f6aa9703e10119f05d578ad (patch)
treea19f805f1a1d564317e26a15b53bab787ef217a2 /src/librustc_interface
parenta3639c68595e59a17884c70d9e1881a00e789bfc (diff)
downloadrust-1a1067d1a537d6495f6aa9703e10119f05d578ad.tar.gz
rust-1a1067d1a537d6495f6aa9703e10119f05d578ad.zip
Make the default parallelism 1
This changes the default parallelism for parallel compilers to one,
instead of the previous default, which was "num cpus". This is likely
not an optimal default long-term, but it is a good default for testing
whether parallel compilers are not a significant regression over a
sequential compiler.

Notably, this in theory makes a parallel-enabled compiler behave
exactly like a sequential compiler with respect to the jobserver.
Diffstat (limited to 'src/librustc_interface')
-rw-r--r--src/librustc_interface/interface.rs5
-rw-r--r--src/librustc_interface/util.rs6
2 files changed, 7 insertions, 4 deletions
diff --git a/src/librustc_interface/interface.rs b/src/librustc_interface/interface.rs
index fef60a47dc4..dae8fb242d5 100644
--- a/src/librustc_interface/interface.rs
+++ b/src/librustc_interface/interface.rs
@@ -147,5 +147,8 @@ where
     F: FnOnce() -> R + Send,
     R: Send,
 {
-    util::spawn_thread_pool(edition, None, &None, f)
+    // the 1 here is duplicating code in config.opts.debugging_opts.threads
+    // which also defaults to 1; it ultimately doesn't matter as the default
+    // isn't threaded, and just ignores this parameter
+    util::spawn_thread_pool(edition, 1, &None, f)
 }
diff --git a/src/librustc_interface/util.rs b/src/librustc_interface/util.rs
index b81f814de0f..0439aaa9463 100644
--- a/src/librustc_interface/util.rs
+++ b/src/librustc_interface/util.rs
@@ -173,7 +173,7 @@ pub fn scoped_thread<F: FnOnce() -> R + Send, R: Send>(cfg: thread::Builder, f:
 #[cfg(not(parallel_compiler))]
 pub fn spawn_thread_pool<F: FnOnce() -> R + Send, R: Send>(
     edition: Edition,
-    _threads: Option<usize>,
+    _threads: usize,
     stderr: &Option<Arc<Mutex<Vec<u8>>>>,
     f: F,
 ) -> R {
@@ -198,7 +198,7 @@ pub fn spawn_thread_pool<F: FnOnce() -> R + Send, R: Send>(
 #[cfg(parallel_compiler)]
 pub fn spawn_thread_pool<F: FnOnce() -> R + Send, R: Send>(
     edition: Edition,
-    threads: Option<usize>,
+    threads: usize,
     stderr: &Option<Arc<Mutex<Vec<u8>>>>,
     f: F,
 ) -> R {
@@ -209,7 +209,7 @@ pub fn spawn_thread_pool<F: FnOnce() -> R + Send, R: Send>(
     let mut config = ThreadPoolBuilder::new()
         .acquire_thread_handler(jobserver::acquire_thread)
         .release_thread_handler(jobserver::release_thread)
-        .num_threads(Session::threads_from_count(threads))
+        .num_threads(threads)
         .deadlock_handler(|| unsafe { ty::query::handle_deadlock() });
 
     if let Some(size) = get_stack_size() {