Merge branch 'trunk' into improve-dependency-solving

This commit is contained in:
Richard Feldman 2020-10-12 10:23:53 -04:00 committed by GitHub
commit a3d81108c3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 37 additions and 11 deletions

View file

@ -823,8 +823,15 @@ fn load<'a>(
where
{
// Reserve one CPU for the main thread, and let all the others be eligible
// to spawn workers.
let num_workers = num_cpus::get() - 1;
// to spawn workers. We use .max(2) to enforce that we always
// end up with at least 1 worker - since (.max(2) - 1) will
// always return a number that's at least 1. Using
// .max(2) on the initial number of CPUs instead of
// doing .max(1) on the entire expression guards against
// num_cpus returning 0, while also avoiding wrapping
// unsigned subtraction overflow.
let num_workers = num_cpus::get().max(2) - 1;
let worker_arenas = arena.alloc(bumpalo::collections::Vec::with_capacity_in(
num_workers,
arena,