diff --git a/core/src/accounts_hash_verifier.rs b/core/src/accounts_hash_verifier.rs index c9904b3272..4574b19919 100644 --- a/core/src/accounts_hash_verifier.rs +++ b/core/src/accounts_hash_verifier.rs @@ -6,11 +6,9 @@ use { crossbeam_channel::RecvTimeoutError, - rayon::ThreadPool, solana_gossip::cluster_info::{ClusterInfo, MAX_SNAPSHOT_HASHES}, solana_measure::measure::Measure, solana_runtime::{ - accounts_db, accounts_hash::{CalcAccountsHashConfig, HashStats}, snapshot_config::SnapshotConfig, snapshot_package::{ @@ -54,7 +52,6 @@ impl AccountsHashVerifier { .name("solana-hash-accounts".to_string()) .spawn(move || { let mut hashes = vec![]; - let mut thread_pool = None; loop { if exit.load(Ordering::Relaxed) { break; @@ -62,11 +59,6 @@ impl AccountsHashVerifier { match accounts_package_receiver.recv_timeout(Duration::from_secs(1)) { Ok(accounts_package) => { - if accounts_package.hash_for_testing.is_some() && thread_pool.is_none() - { - thread_pool = Some(accounts_db::make_min_priority_thread_pool()); - } - Self::process_accounts_package( accounts_package, &cluster_info, @@ -77,7 +69,6 @@ impl AccountsHashVerifier { &exit, fault_injection_rate_slots, snapshot_config.as_ref(), - thread_pool.as_ref(), &ledger_path, ); } @@ -103,10 +94,9 @@ impl AccountsHashVerifier { exit: &Arc, fault_injection_rate_slots: u64, snapshot_config: Option<&SnapshotConfig>, - thread_pool: Option<&ThreadPool>, ledger_path: &Path, ) { - Self::verify_accounts_package_hash(&accounts_package, thread_pool, ledger_path); + Self::verify_accounts_package_hash(&accounts_package, ledger_path); Self::push_accounts_hashes_to_cluster( &accounts_package, @@ -121,11 +111,7 @@ impl AccountsHashVerifier { Self::submit_for_packaging(accounts_package, pending_snapshot_package, snapshot_config); } - fn verify_accounts_package_hash( - accounts_package: &AccountsPackage, - thread_pool: Option<&ThreadPool>, - ledger_path: &Path, - ) { + fn verify_accounts_package_hash(accounts_package: &AccountsPackage, ledger_path: &Path) { let mut measure_hash = Measure::start("hash"); if let Some(expected_hash) = accounts_package.hash_for_testing { let sorted_storages = SortedStorages::new(&accounts_package.snapshot_storages); @@ -135,7 +121,7 @@ impl AccountsHashVerifier { .calculate_accounts_hash_without_index(&mut CalcAccountsHashConfig { accounts_hash_cache_path: ledger_path, storages: &sorted_storages, - thread_pool, + use_bg_thread_pool: true, stats: HashStats::default(), check_hash: false, accounts_cache_and_ancestors: None, @@ -387,7 +373,6 @@ mod tests { &exit, 0, Some(&snapshot_config), - None, ledger_path.path(), ); diff --git a/runtime/src/accounts_db.rs b/runtime/src/accounts_db.rs index ba868ab416..7889a61d8e 100644 --- a/runtime/src/accounts_db.rs +++ b/runtime/src/accounts_db.rs @@ -5521,15 +5521,10 @@ impl AccountsDb { ..HashStats::default() }; - let thread_pool = if is_startup { - None - } else { - Some(&self.thread_pool_clean) - }; self.calculate_accounts_hash_without_index(&mut CalcAccountsHashConfig { accounts_hash_cache_path: &self.accounts_hash_cache_path, storages: &storages, - thread_pool, + use_bg_thread_pool: !is_startup, stats: timings, check_hash, accounts_cache_and_ancestors, @@ -5735,7 +5730,7 @@ impl AccountsDb { ) -> Result<(Hash, u64), BankHashVerificationError> { let (num_hash_scan_passes, bins_per_pass) = Self::bins_per_pass(config.num_hash_scan_passes); - let thread_pool = config.thread_pool; + let use_bg_thread_pool = config.use_bg_thread_pool; let mut scan_and_hash = move || { let mut previous_pass = PreviousPass::default(); let mut final_result = (Hash::default(), 0); @@ -5780,8 +5775,8 @@ impl AccountsDb { ); Ok(final_result) }; - if let Some(thread_pool) = thread_pool { - thread_pool.install(scan_and_hash) + if use_bg_thread_pool { + self.thread_pool_clean.install(scan_and_hash) } else { scan_and_hash() } @@ -7910,7 +7905,7 @@ pub mod tests { .calculate_accounts_hash_without_index(&mut CalcAccountsHashConfig { accounts_hash_cache_path: TempDir::new().unwrap().path(), storages: &get_storage_refs(&storages), - thread_pool: None, + use_bg_thread_pool: false, stats: HashStats::default(), check_hash: false, accounts_cache_and_ancestors: None, @@ -7937,7 +7932,7 @@ pub mod tests { .calculate_accounts_hash_without_index(&mut CalcAccountsHashConfig { accounts_hash_cache_path: TempDir::new().unwrap().path(), storages: &get_storage_refs(&storages), - thread_pool: None, + use_bg_thread_pool: false, stats: HashStats::default(), check_hash: false, accounts_cache_and_ancestors: None, diff --git a/runtime/src/accounts_hash.rs b/runtime/src/accounts_hash.rs index 7c8b69234d..7014f7301d 100644 --- a/runtime/src/accounts_hash.rs +++ b/runtime/src/accounts_hash.rs @@ -4,7 +4,7 @@ use { sorted_storages::SortedStorages, }, log::*, - rayon::{prelude::*, ThreadPool}, + rayon::prelude::*, solana_measure::measure::Measure, solana_sdk::{ hash::{Hash, Hasher}, @@ -26,7 +26,7 @@ pub struct PreviousPass { pub struct CalcAccountsHashConfig<'a> { pub accounts_hash_cache_path: &'a Path, pub storages: &'a SortedStorages<'a>, - pub thread_pool: Option<&'a ThreadPool>, + pub use_bg_thread_pool: bool, pub stats: HashStats, pub check_hash: bool, pub accounts_cache_and_ancestors: Option<(