Skip to content

Commit

Permalink
Allow specifying max-blocking-threads
Browse files Browse the repository at this point in the history
  • Loading branch information
wykurz committed Dec 1, 2023
1 parent d392d5d commit eec8b75
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 3 deletions.
4 changes: 4 additions & 0 deletions common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ pub fn run<Fut>(
quiet: bool,
verbose: u8,
max_workers: usize,
max_blocking_threads: usize,
func: impl FnOnce() -> Fut,
) -> Result<()>
where
Expand All @@ -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)");
}
Expand Down
12 changes: 11 additions & 1 deletion rcp/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(())
}
12 changes: 11 additions & 1 deletion rlink/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(())
}
12 changes: 11 additions & 1 deletion rrm/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<()> {
Expand Down Expand Up @@ -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(())
}

0 comments on commit eec8b75

Please sign in to comment.