Skip to content

Commit

Permalink
Thread manager instantiation in the validator (#4603)
Browse files Browse the repository at this point in the history
* enable agave to start with default config for thread manager
* make it possible to create thread manager without consuming the config
* relax thread name length constraints
---------
Co-authored-by: Alex Pyattaev <[email protected]>
  • Loading branch information
alexpyattaev authored Jan 28, 2025
1 parent 94841a8 commit e48672c
Show file tree
Hide file tree
Showing 15 changed files with 294 additions and 52 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ codecov = { repository = "solana-labs/solana", branch = "master", service = "git

[dependencies]
agave-banking-stage-ingress-types = { workspace = true }
agave-thread-manager = { workspace = true }
agave-transaction-view = { workspace = true }
ahash = { workspace = true }
anyhow = { workspace = true }
Expand Down
7 changes: 7 additions & 0 deletions core/src/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use {
tpu::{Tpu, TpuSockets, DEFAULT_TPU_COALESCE},
tvu::{Tvu, TvuConfig, TvuSockets},
},
agave_thread_manager::{ThreadManager, ThreadManagerConfig},
anyhow::{anyhow, Context, Result},
crossbeam_channel::{bounded, unbounded, Receiver},
lazy_static::lazy_static,
Expand Down Expand Up @@ -313,6 +314,7 @@ pub struct ValidatorConfig {
pub replay_forks_threads: NonZeroUsize,
pub replay_transactions_threads: NonZeroUsize,
pub tvu_shred_sigverify_threads: NonZeroUsize,
pub thread_manager_config: ThreadManagerConfig,
pub delay_leader_block_for_pending_fork: bool,
}

Expand Down Expand Up @@ -385,6 +387,7 @@ impl Default for ValidatorConfig {
rayon_global_threads: NonZeroUsize::new(1).expect("1 is non-zero"),
replay_forks_threads: NonZeroUsize::new(1).expect("1 is non-zero"),
replay_transactions_threads: NonZeroUsize::new(1).expect("1 is non-zero"),
thread_manager_config: ThreadManagerConfig::default_for_agave(),
tvu_shred_sigverify_threads: NonZeroUsize::new(1).expect("1 is non-zero"),
delay_leader_block_for_pending_fork: false,
}
Expand Down Expand Up @@ -588,6 +591,7 @@ pub struct Validator {
repair_quic_endpoints: Option<[Endpoint; 3]>,
repair_quic_endpoints_runtime: Option<TokioRuntime>,
repair_quic_endpoints_join_handle: Option<repair::quic_endpoint::AsyncTryJoinHandle>,
thread_manager: ThreadManager,
}

impl Validator {
Expand Down Expand Up @@ -619,6 +623,7 @@ impl Validator {

let start_time = Instant::now();

let thread_manager = ThreadManager::new(&config.thread_manager_config)?;
// Initialize the global rayon pool first to ensure the value in config
// is honored. Otherwise, some code accessing the global pool could
// cause it to get initialized with Rayon's default (not ours)
Expand Down Expand Up @@ -1659,6 +1664,7 @@ impl Validator {
repair_quic_endpoints,
repair_quic_endpoints_runtime,
repair_quic_endpoints_join_handle,
thread_manager,
})
}

Expand Down Expand Up @@ -1816,6 +1822,7 @@ impl Validator {
self.poh_timing_report_service
.join()
.expect("poh_timing_report_service");
self.thread_manager.destroy();
}
}

Expand Down
1 change: 1 addition & 0 deletions local-cluster/src/validator_configs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ pub fn safe_clone_config(config: &ValidatorConfig) -> ValidatorConfig {
replay_forks_threads: config.replay_forks_threads,
replay_transactions_threads: config.replay_transactions_threads,
tvu_shred_sigverify_threads: config.tvu_shred_sigverify_threads,
thread_manager_config: config.thread_manager_config.clone(),
delay_leader_block_for_pending_fork: config.delay_leader_block_for_pending_fork,
}
}
Expand Down
96 changes: 93 additions & 3 deletions programs/sbf/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

72 changes: 71 additions & 1 deletion svm/examples/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion thread-manager/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ serde = { workspace = true, features = ["derive"] }
solana-metrics = { workspace = true }
thread-priority = { workspace = true }
tokio = { workspace = true, features = ["time", "rt-multi-thread"] }
toml = { workspace = true }

[target.'cfg(target_os = "linux")'.dependencies]
affinity = "0.1.2"
Expand All @@ -31,7 +32,6 @@ axum = { workspace = true }
env_logger = { workspace = true }
hyper = { workspace = true, features = ["http1", "client", "stream", "tcp"] }
serde_json = { workspace = true }
toml = { workspace = true }
tower = { workspace = true }

[features]
Expand Down
Loading

0 comments on commit e48672c

Please sign in to comment.