Skip to content

Commit

Permalink
Use logical CPUs instead of physical by default (#2391)
Browse files Browse the repository at this point in the history
Some reasons to prefer logical count as the default:

- Chips reporting many logical CPUs vs physical, such as via
hyperthreading, probably know better than us about the workload the CPUs
can handle.
- The logical count (`num_cpus::get()`) takes into consideration
schedular affinity, and cgroups CPU quota, in case the user wants to
limit the amount of CPUs a process can use.

Closes #2269
  • Loading branch information
seanmonstar authored Apr 9, 2020
1 parent 58ba45a commit d294c99
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tokio/src/loom/std/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub(crate) mod sync {
pub(crate) mod sys {
#[cfg(feature = "rt-threaded")]
pub(crate) fn num_cpus() -> usize {
usize::max(1, num_cpus::get_physical())
usize::max(1, num_cpus::get())
}

#[cfg(not(feature = "rt-threaded"))]
Expand Down

0 comments on commit d294c99

Please sign in to comment.