calc hash uses self.thread_pool_clean (#23881)

This commit is contained in:
Jeff Washington (jwash)
2022-03-23 20:52:38 -05:00
committed by GitHub
parent 6428602cd9
commit 3e22d4b286
3 changed files with 11 additions and 31 deletions

View File

@@ -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,

View File

@@ -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<(