diff options
| author | Mark Rousskov <mark.simulacrum@gmail.com> | 2019-12-16 16:23:07 -0500 |
|---|---|---|
| committer | Mark Rousskov <mark.simulacrum@gmail.com> | 2019-12-16 18:31:56 -0500 |
| commit | f6281e858699b482088e5f5cadcc6a0b7ab9e975 (patch) | |
| tree | 58cd07dc6e62d131978a977bd8d261e466911353 | |
| parent | f0d4b571936d4072ed90ab7750636f68f1443b3e (diff) | |
Change the default thread count to min(4, vCPUs)
This avoids the problems of high thread counts (i.e., contention in the kernel on the jobserver pipe due to thundering herd of readers) while stil giving rustc some parallelism to work with.
| -rw-r--r-- | src/librustc_session/config.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/librustc_session/config.rs b/src/librustc_session/config.rs index 7f3bab8f232..359c8b3e73a 100644 --- a/src/librustc_session/config.rs +++ b/src/librustc_session/config.rs @@ -1358,11 +1358,11 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options, "prints the LLVM optimization passes being run"), ast_json: bool = (false, parse_bool, [UNTRACKED], "print the AST as JSON and halt"), - // We default to 1 here since we want to behave like - // a sequential compiler for now. This'll likely be adjusted - // in the future. Note that -Zthreads=0 is the way to get - // the num_cpus behavior. - threads: usize = (1, parse_threads, [UNTRACKED], + // We default to min(4, vCPUs) here since we want to avoid spawning *too* + // many threads -- that causes scalability issues due to contention on + // the jobserver pipe (at least) -- but 4 is a reasonable amount on systems + // with lots of cores. + threads: usize = (std::cmp::min(::num_cpus::get(), 4), parse_threads, [UNTRACKED], "use a thread pool with N threads"), ast_json_noexpand: bool = (false, parse_bool, [UNTRACKED], "print the pre-expansion AST as JSON and halt"), |
