From eec8b756bfcfff904b5a2b0ffcce10f494771724 Mon Sep 17 00:00:00 2001 From: Mateusz Wykurz Date: Thu, 30 Nov 2023 20:58:20 -0700 Subject: [PATCH] Allow specifying max-blocking-threads --- common/src/lib.rs | 4 ++++ rcp/src/main.rs | 12 +++++++++++- rlink/src/main.rs | 12 +++++++++++- rrm/src/main.rs | 12 +++++++++++- 4 files changed, 37 insertions(+), 3 deletions(-) diff --git a/common/src/lib.rs b/common/src/lib.rs index abd5dfd..31bce4f 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -120,6 +120,7 @@ pub fn run( quiet: bool, verbose: u8, max_workers: usize, + max_blocking_threads: usize, func: impl FnOnce() -> Fut, ) -> Result<()> where @@ -146,6 +147,9 @@ where if max_workers > 0 { builder.worker_threads(max_workers); } + if max_blocking_threads > 0 { + builder.max_blocking_threads(max_blocking_threads); + } if !sysinfo::set_open_files_limit(isize::MAX) { info!("Failed to update the open files limit (expeted on non-linux targets)"); } diff --git a/rcp/src/main.rs b/rcp/src/main.rs index 9ce8293..d595868 100644 --- a/rcp/src/main.rs +++ b/rcp/src/main.rs @@ -40,6 +40,10 @@ struct Args { #[structopt(long, default_value = "0")] max_workers: usize, + /// Number of blocking worker threads, 0 means Tokio runtime default (512) + #[structopt(long, default_value = "0")] + max_blocking_threads: usize, + /// File copy read buffer size #[structopt(long, default_value = "128KiB")] read_buffer: String, @@ -139,6 +143,12 @@ fn main() -> Result<()> { let args = args.clone(); || async_main(args) }; - common::run(args.quiet, args.verbose, args.max_workers, func)?; + common::run( + args.quiet, + args.verbose, + args.max_workers, + args.max_blocking_threads, + func, + )?; Ok(()) } diff --git a/rlink/src/main.rs b/rlink/src/main.rs index e506985..5f8fd56 100644 --- a/rlink/src/main.rs +++ b/rlink/src/main.rs @@ -44,6 +44,10 @@ struct Args { #[structopt(long, default_value = "0")] max_workers: usize, + /// Number of blocking worker threads, 0 means Tokio runtime default (512) + #[structopt(long, default_value = "0")] + max_blocking_threads: usize, + /// File copy read buffer size #[structopt(long, default_value = "128KiB")] read_buffer: String, @@ -94,6 +98,12 @@ fn main() -> Result<()> { let args = args.clone(); || async_main(args) }; - common::run(args.quiet, args.verbose, args.max_workers, func)?; + common::run( + args.quiet, + args.verbose, + args.max_workers, + args.max_blocking_threads, + func, + )?; Ok(()) } diff --git a/rrm/src/main.rs b/rrm/src/main.rs index f1ea6bc..1e2dacf 100644 --- a/rrm/src/main.rs +++ b/rrm/src/main.rs @@ -27,6 +27,10 @@ struct Args { /// Number of worker threads, 0 means number of cores #[structopt(long, default_value = "0")] max_workers: usize, + + /// Number of blocking worker threads, 0 means Tokio runtime default (512) + #[structopt(long, default_value = "0")] + max_blocking_threads: usize, } async fn async_main(args: Args) -> Result<()> { @@ -60,6 +64,12 @@ fn main() -> Result<()> { let args = args.clone(); || async_main(args) }; - common::run(args.quiet, args.verbose, args.max_workers, func)?; + common::run( + args.quiet, + args.verbose, + args.max_workers, + args.max_blocking_threads, + func, + )?; Ok(()) }