set sensible worker thread limits again but allow full control to caller

This commit is contained in:
James Wilson
2021-08-06 17:49:04 +01:00
parent 88c3db3562
commit 78ad7115e5
2 changed files with 14 additions and 10 deletions
+6 -5
View File
@@ -60,9 +60,9 @@ struct Opts {
#[structopt(long, default_value = "10")]
feed_timeout: u64,
/// Number of worker threads to spawn. If "0" is given, use the number of CPUs available
/// on the machine.
#[structopt(long, default_value = "0")]
worker_threads: usize,
/// on the machine. If no value is given, use an internal default that we have deemed sane.
#[structopt(long)]
worker_threads: Option<usize>,
}
fn main() {
@@ -76,8 +76,9 @@ fn main() {
log::info!("Starting Telemetry Core version: {}", VERSION);
let worker_threads = match opts.worker_threads {
0 => num_cpus::get(),
n => n,
Some(0) => num_cpus::get(),
Some(n) => n,
None => usize::min(num_cpus::get(), 8)
};
tokio::runtime::Builder::new_multi_thread()
+8 -5
View File
@@ -81,9 +81,9 @@ struct Opts {
#[structopt(long, default_value = "600")]
node_block_seconds: u64,
/// Number of worker threads to spawn. If "0" is given, use the number of CPUs available
/// on the machine.
#[structopt(long, default_value = "0")]
worker_threads: usize,
/// on the machine. If no value is given, use an internal default that we have deemed sane.
#[structopt(long)]
worker_threads: Option<usize>,
}
fn main() {
@@ -97,8 +97,11 @@ fn main() {
log::info!("Starting Telemetry Shard version: {}", VERSION);
let worker_threads = match opts.worker_threads {
0 => num_cpus::get(),
n => n,
Some(0) => num_cpus::get(),
Some(n) => n,
// By default, use a max of 4 worker threads, as we don't
// expect to need a lot of parallelism in shards.
None => usize::min(num_cpus::get(), 4)
};
tokio::runtime::Builder::new_multi_thread()