mirror of
https://github.com/pezkuwichain/pezkuwi-telemetry.git
synced 2026-07-21 15:35:44 +00:00
set sensible worker thread limits again but allow full control to caller
This commit is contained in:
@@ -60,9 +60,9 @@ struct Opts {
|
|||||||
#[structopt(long, default_value = "10")]
|
#[structopt(long, default_value = "10")]
|
||||||
feed_timeout: u64,
|
feed_timeout: u64,
|
||||||
/// Number of worker threads to spawn. If "0" is given, use the number of CPUs available
|
/// Number of worker threads to spawn. If "0" is given, use the number of CPUs available
|
||||||
/// on the machine.
|
/// on the machine. If no value is given, use an internal default that we have deemed sane.
|
||||||
#[structopt(long, default_value = "0")]
|
#[structopt(long)]
|
||||||
worker_threads: usize,
|
worker_threads: Option<usize>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
@@ -76,8 +76,9 @@ fn main() {
|
|||||||
log::info!("Starting Telemetry Core version: {}", VERSION);
|
log::info!("Starting Telemetry Core version: {}", VERSION);
|
||||||
|
|
||||||
let worker_threads = match opts.worker_threads {
|
let worker_threads = match opts.worker_threads {
|
||||||
0 => num_cpus::get(),
|
Some(0) => num_cpus::get(),
|
||||||
n => n,
|
Some(n) => n,
|
||||||
|
None => usize::min(num_cpus::get(), 8)
|
||||||
};
|
};
|
||||||
|
|
||||||
tokio::runtime::Builder::new_multi_thread()
|
tokio::runtime::Builder::new_multi_thread()
|
||||||
|
|||||||
@@ -81,9 +81,9 @@ struct Opts {
|
|||||||
#[structopt(long, default_value = "600")]
|
#[structopt(long, default_value = "600")]
|
||||||
node_block_seconds: u64,
|
node_block_seconds: u64,
|
||||||
/// Number of worker threads to spawn. If "0" is given, use the number of CPUs available
|
/// Number of worker threads to spawn. If "0" is given, use the number of CPUs available
|
||||||
/// on the machine.
|
/// on the machine. If no value is given, use an internal default that we have deemed sane.
|
||||||
#[structopt(long, default_value = "0")]
|
#[structopt(long)]
|
||||||
worker_threads: usize,
|
worker_threads: Option<usize>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
@@ -97,8 +97,11 @@ fn main() {
|
|||||||
log::info!("Starting Telemetry Shard version: {}", VERSION);
|
log::info!("Starting Telemetry Shard version: {}", VERSION);
|
||||||
|
|
||||||
let worker_threads = match opts.worker_threads {
|
let worker_threads = match opts.worker_threads {
|
||||||
0 => num_cpus::get(),
|
Some(0) => num_cpus::get(),
|
||||||
n => n,
|
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()
|
tokio::runtime::Builder::new_multi_thread()
|
||||||
|
|||||||
Reference in New Issue
Block a user