mononoke: use logical number of cpus in our runtime

Summary:
We are using older version of tokio which spawns as many threads as we have
physical cores instead of the number of logical cores. It was fixed in
https://github.com/tokio-rs/tokio/issues/2269 but we can't use it yet because
we are waiting for another fix to be released -
https://github.com/rust-lang/futures-rs/pull/2154.

For now let's hardcode it in mononoke

Reviewed By: krallin

Differential Revision: D23599140

fbshipit-source-id: 80685651a7a29ba8938d9aa59770f191f7c42b8b
This commit is contained in:
Stanislau Hlebik 2020-09-09 09:23:50 -07:00 committed by Facebook GitHub Bot
parent f87db3eecf
commit b5f1e53cd6
2 changed files with 5 additions and 0 deletions

View File

@ -42,6 +42,7 @@ lazy_static = "1.0"
libc = "0.2" libc = "0.2"
log = { version = "0.4.8", features = ["kv_unstable"] } log = { version = "0.4.8", features = ["kv_unstable"] }
maplit = "1.0" maplit = "1.0"
num_cpus = "1.11"
serde = { version = "1.0", features = ["derive", "rc"] } serde = { version = "1.0", features = ["derive", "rc"] }
slog = { version = "2.5", features = ["max_level_debug"] } slog = { version = "2.5", features = ["max_level_debug"] }
slog-term = "2.4.2" slog-term = "2.4.2"

View File

@ -162,6 +162,10 @@ pub fn create_runtime(
builder.name_prefix(log_thread_name_prefix.unwrap_or("tk")); builder.name_prefix(log_thread_name_prefix.unwrap_or("tk"));
if let Some(core_threads) = core_threads { if let Some(core_threads) = core_threads {
builder.core_threads(core_threads); builder.core_threads(core_threads);
} else {
// TODO(stash) T75113443 remove when
// https://github.com/tokio-rs/tokio/issues/2269 is landed
builder.core_threads(num_cpus::get());
} }
builder.build() builder.build()
} }