Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2.0: Bound default value for thread pool args (backport of #2599) #2662

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions validator/src/cli/thread_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ pub struct DefaultThreadArgs {
impl Default for DefaultThreadArgs {
fn default() -> Self {
Self {
ip_echo_server_threads: IpEchoServerThreadsArg::default().to_string(),
replay_forks_threads: ReplayForksThreadsArg::default().to_string(),
replay_transactions_threads: ReplayTransactionsThreadsArg::default().to_string(),
tvu_receive_threads: TvuReceiveThreadsArg::default().to_string(),
ip_echo_server_threads: IpEchoServerThreadsArg::bounded_default().to_string(),
replay_forks_threads: ReplayForksThreadsArg::bounded_default().to_string(),
replay_transactions_threads: ReplayTransactionsThreadsArg::bounded_default()
.to_string(),
tvu_receive_threads: TvuReceiveThreadsArg::bounded_default().to_string(),
}
}
}
Expand Down Expand Up @@ -85,6 +86,12 @@ trait ThreadArg {

/// The default number of threads
fn default() -> usize;
/// The default number of threads, bounded by Self::max()
/// This prevents potential CLAP issues on low core count machines where
/// a fixed value in Self::default() could be greater than Self::max()
fn bounded_default() -> usize {
std::cmp::min(Self::default(), Self::max())
}
/// The minimum allowed number of threads (inclusive)
fn min() -> usize {
1
Expand Down