Skip to content

Commit

Permalink
Change the default thread count to min(4, vCPUs)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Mark-Simulacrum committed Dec 16, 2019
1 parent f0d4b57 commit f6281e8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/librustc_session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down

0 comments on commit f6281e8

Please sign in to comment.