num-cpus to worker-threads; more accurate name

This commit is contained in:
James Wilson
2021-08-05 11:31:47 +01:00
parent 5c5c7e592a
commit acfe3d45d1
4 changed files with 20 additions and 20 deletions
+3 -3
View File
@@ -62,7 +62,7 @@ struct Opts {
/// Number of worker threads to spawn. Defaults to the number of CPUs on the machine. /// Number of worker threads to spawn. Defaults to the number of CPUs on the machine.
/// If "0" is given, use the number of CPUs available on the machine. /// If "0" is given, use the number of CPUs available on the machine.
#[structopt(long)] #[structopt(long)]
num_cpus: Option<usize>, worker_threads: Option<usize>,
} }
fn main() { fn main() {
@@ -75,13 +75,13 @@ fn main() {
log::info!("Starting Telemetry Core version: {}", VERSION); log::info!("Starting Telemetry Core version: {}", VERSION);
let num_cpus_to_use = opts.num_cpus let worker_threads = opts.worker_threads
.and_then(|n| if n == 0 { None } else { Some(n) }) .and_then(|n| if n == 0 { None } else { Some(n) })
.unwrap_or_else(|| num_cpus::get()); .unwrap_or_else(|| num_cpus::get());
tokio::runtime::Builder::new_multi_thread() tokio::runtime::Builder::new_multi_thread()
.enable_all() .enable_all()
.worker_threads(num_cpus_to_use) .worker_threads(worker_threads)
.build() .build()
.unwrap() .unwrap()
.block_on(async { .block_on(async {
+6 -6
View File
@@ -76,11 +76,11 @@ async fn run_soak_test(opts: SoakTestOpts) {
let mut server = start_server( let mut server = start_server(
true, true,
CoreOpts { CoreOpts {
num_cpus: opts.num_core_cpus, worker_threads: opts.core_worker_threads,
..Default::default() ..Default::default()
}, },
ShardOpts { ShardOpts {
num_cpus: opts.num_shard_cpus, worker_threads: opts.shard_worker_threads,
..Default::default() ..Default::default()
}, },
).await; ).await;
@@ -259,11 +259,11 @@ async fn run_realistic_soak_test(opts: SoakTestOpts) {
let mut server = start_server( let mut server = start_server(
true, true,
CoreOpts { CoreOpts {
num_cpus: opts.num_core_cpus, worker_threads: opts.core_worker_threads,
..Default::default() ..Default::default()
}, },
ShardOpts { ShardOpts {
num_cpus: opts.num_shard_cpus, worker_threads: opts.shard_worker_threads,
..Default::default() ..Default::default()
}, },
).await; ).await;
@@ -394,10 +394,10 @@ struct SoakTestOpts {
nodes: usize, nodes: usize,
/// Number of worker threads the core will use /// Number of worker threads the core will use
#[structopt(long)] #[structopt(long)]
num_core_cpus: Option<usize>, core_worker_threads: Option<usize>,
/// Number of worker threads each shard will use /// Number of worker threads each shard will use
#[structopt(long)] #[structopt(long)]
num_shard_cpus: Option<usize>, shard_worker_threads: Option<usize>,
} }
/// Get soak test args from an envvar and parse them via structopt. /// Get soak test args from an envvar and parse them via structopt.
+3 -3
View File
@@ -83,7 +83,7 @@ struct Opts {
/// Number of worker threads to spawn. Defaults to the number of CPUs on the machine. /// Number of worker threads to spawn. Defaults to the number of CPUs on the machine.
/// If "0" is given, use the number of CPUs available on the machine. /// If "0" is given, use the number of CPUs available on the machine.
#[structopt(long)] #[structopt(long)]
num_cpus: Option<usize>, worker_threads: Option<usize>,
} }
fn main() { fn main() {
@@ -96,13 +96,13 @@ fn main() {
log::info!("Starting Telemetry Shard version: {}", VERSION); log::info!("Starting Telemetry Shard version: {}", VERSION);
let num_cpus_to_use = opts.num_cpus let worker_threads = opts.worker_threads
.and_then(|n| if n == 0 { None } else { Some(n) }) .and_then(|n| if n == 0 { None } else { Some(n) })
.unwrap_or_else(|| num_cpus::get()); .unwrap_or_else(|| num_cpus::get());
tokio::runtime::Builder::new_multi_thread() tokio::runtime::Builder::new_multi_thread()
.enable_all() .enable_all()
.worker_threads(num_cpus_to_use) .worker_threads(worker_threads)
.build() .build()
.unwrap() .unwrap()
.block_on(async { .block_on(async {
@@ -20,14 +20,14 @@ use crate::server::{self, Command, Server};
/// Additional options to pass to the core command. /// Additional options to pass to the core command.
pub struct CoreOpts { pub struct CoreOpts {
pub feed_timeout: Option<u64>, pub feed_timeout: Option<u64>,
pub num_cpus: Option<usize>, pub worker_threads: Option<usize>,
} }
impl Default for CoreOpts { impl Default for CoreOpts {
fn default() -> Self { fn default() -> Self {
Self { Self {
feed_timeout: None, feed_timeout: None,
num_cpus: None worker_threads: None
} }
} }
} }
@@ -37,7 +37,7 @@ pub struct ShardOpts {
pub max_nodes_per_connection: Option<usize>, pub max_nodes_per_connection: Option<usize>,
pub max_node_data_per_second: Option<usize>, pub max_node_data_per_second: Option<usize>,
pub node_block_seconds: Option<u64>, pub node_block_seconds: Option<u64>,
pub num_cpus: Option<usize>, pub worker_threads: Option<usize>,
} }
impl Default for ShardOpts { impl Default for ShardOpts {
@@ -46,7 +46,7 @@ impl Default for ShardOpts {
max_nodes_per_connection: None, max_nodes_per_connection: None,
max_node_data_per_second: None, max_node_data_per_second: None,
node_block_seconds: None, node_block_seconds: None,
num_cpus: None worker_threads: None
} }
} }
} }
@@ -120,9 +120,9 @@ pub async fn start_server(
.arg("--node-block-seconds") .arg("--node-block-seconds")
.arg(val.to_string()); .arg(val.to_string());
} }
if let Some(val) = shard_opts.num_cpus { if let Some(val) = shard_opts.worker_threads {
shard_command = shard_command shard_command = shard_command
.arg("--num-cpus") .arg("--worker-threads")
.arg(val.to_string()); .arg(val.to_string());
} }
@@ -138,8 +138,8 @@ pub async fn start_server(
if let Some(val) = core_opts.feed_timeout { if let Some(val) = core_opts.feed_timeout {
core_command = core_command.arg("--feed-timeout").arg(val.to_string()); core_command = core_command.arg("--feed-timeout").arg(val.to_string());
} }
if let Some(val) = core_opts.num_cpus { if let Some(val) = core_opts.worker_threads {
core_command = core_command.arg("--num-cpus").arg(val.to_string()); core_command = core_command.arg("--worker-threads").arg(val.to_string());
} }
// Star the server // Star the server