mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 15:21:12 +00:00
Always use a minimum of 1 worker
This commit is contained in:
parent
0ad5286ab8
commit
2758c7f04c
2 changed files with 16 additions and 4 deletions
|
@ -350,8 +350,14 @@ pub fn load(
|
||||||
let arena = Bump::new();
|
let arena = Bump::new();
|
||||||
|
|
||||||
// Reserve one CPU for the main thread, and let all the others be eligible
|
// Reserve one CPU for the main thread, and let all the others be eligible
|
||||||
// to spawn workers.
|
// to spawn workers. We use .max(2) to enforce that we always
|
||||||
let num_workers = num_cpus::get() - 1;
|
// 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 mut worker_arenas = bumpalo::collections::Vec::with_capacity_in(num_workers, &arena);
|
let mut worker_arenas = bumpalo::collections::Vec::with_capacity_in(num_workers, &arena);
|
||||||
|
|
||||||
|
|
|
@ -399,8 +399,14 @@ pub fn load(
|
||||||
let arena = Bump::new();
|
let arena = Bump::new();
|
||||||
|
|
||||||
// Reserve one CPU for the main thread, and let all the others be eligible
|
// Reserve one CPU for the main thread, and let all the others be eligible
|
||||||
// to spawn workers.
|
// to spawn workers. We use .max(2) to enforce that we always
|
||||||
let num_workers = num_cpus::get() - 1;
|
// 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 mut worker_arenas = bumpalo::collections::Vec::with_capacity_in(num_workers, &arena);
|
let mut worker_arenas = bumpalo::collections::Vec::with_capacity_in(num_workers, &arena);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue