calc hash uses self.thread_pool_clean (#23881)
This commit is contained in:
parent
6428602cd9
commit
3e22d4b286
|
@ -6,11 +6,9 @@
|
||||||
|
|
||||||
use {
|
use {
|
||||||
crossbeam_channel::RecvTimeoutError,
|
crossbeam_channel::RecvTimeoutError,
|
||||||
rayon::ThreadPool,
|
|
||||||
solana_gossip::cluster_info::{ClusterInfo, MAX_SNAPSHOT_HASHES},
|
solana_gossip::cluster_info::{ClusterInfo, MAX_SNAPSHOT_HASHES},
|
||||||
solana_measure::measure::Measure,
|
solana_measure::measure::Measure,
|
||||||
solana_runtime::{
|
solana_runtime::{
|
||||||
accounts_db,
|
|
||||||
accounts_hash::{CalcAccountsHashConfig, HashStats},
|
accounts_hash::{CalcAccountsHashConfig, HashStats},
|
||||||
snapshot_config::SnapshotConfig,
|
snapshot_config::SnapshotConfig,
|
||||||
snapshot_package::{
|
snapshot_package::{
|
||||||
|
@ -54,7 +52,6 @@ impl AccountsHashVerifier {
|
||||||
.name("solana-hash-accounts".to_string())
|
.name("solana-hash-accounts".to_string())
|
||||||
.spawn(move || {
|
.spawn(move || {
|
||||||
let mut hashes = vec![];
|
let mut hashes = vec![];
|
||||||
let mut thread_pool = None;
|
|
||||||
loop {
|
loop {
|
||||||
if exit.load(Ordering::Relaxed) {
|
if exit.load(Ordering::Relaxed) {
|
||||||
break;
|
break;
|
||||||
|
@ -62,11 +59,6 @@ impl AccountsHashVerifier {
|
||||||
|
|
||||||
match accounts_package_receiver.recv_timeout(Duration::from_secs(1)) {
|
match accounts_package_receiver.recv_timeout(Duration::from_secs(1)) {
|
||||||
Ok(accounts_package) => {
|
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(
|
Self::process_accounts_package(
|
||||||
accounts_package,
|
accounts_package,
|
||||||
&cluster_info,
|
&cluster_info,
|
||||||
|
@ -77,7 +69,6 @@ impl AccountsHashVerifier {
|
||||||
&exit,
|
&exit,
|
||||||
fault_injection_rate_slots,
|
fault_injection_rate_slots,
|
||||||
snapshot_config.as_ref(),
|
snapshot_config.as_ref(),
|
||||||
thread_pool.as_ref(),
|
|
||||||
&ledger_path,
|
&ledger_path,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -103,10 +94,9 @@ impl AccountsHashVerifier {
|
||||||
exit: &Arc<AtomicBool>,
|
exit: &Arc<AtomicBool>,
|
||||||
fault_injection_rate_slots: u64,
|
fault_injection_rate_slots: u64,
|
||||||
snapshot_config: Option<&SnapshotConfig>,
|
snapshot_config: Option<&SnapshotConfig>,
|
||||||
thread_pool: Option<&ThreadPool>,
|
|
||||||
ledger_path: &Path,
|
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(
|
Self::push_accounts_hashes_to_cluster(
|
||||||
&accounts_package,
|
&accounts_package,
|
||||||
|
@ -121,11 +111,7 @@ impl AccountsHashVerifier {
|
||||||
Self::submit_for_packaging(accounts_package, pending_snapshot_package, snapshot_config);
|
Self::submit_for_packaging(accounts_package, pending_snapshot_package, snapshot_config);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn verify_accounts_package_hash(
|
fn verify_accounts_package_hash(accounts_package: &AccountsPackage, ledger_path: &Path) {
|
||||||
accounts_package: &AccountsPackage,
|
|
||||||
thread_pool: Option<&ThreadPool>,
|
|
||||||
ledger_path: &Path,
|
|
||||||
) {
|
|
||||||
let mut measure_hash = Measure::start("hash");
|
let mut measure_hash = Measure::start("hash");
|
||||||
if let Some(expected_hash) = accounts_package.hash_for_testing {
|
if let Some(expected_hash) = accounts_package.hash_for_testing {
|
||||||
let sorted_storages = SortedStorages::new(&accounts_package.snapshot_storages);
|
let sorted_storages = SortedStorages::new(&accounts_package.snapshot_storages);
|
||||||
|
@ -135,7 +121,7 @@ impl AccountsHashVerifier {
|
||||||
.calculate_accounts_hash_without_index(&mut CalcAccountsHashConfig {
|
.calculate_accounts_hash_without_index(&mut CalcAccountsHashConfig {
|
||||||
accounts_hash_cache_path: ledger_path,
|
accounts_hash_cache_path: ledger_path,
|
||||||
storages: &sorted_storages,
|
storages: &sorted_storages,
|
||||||
thread_pool,
|
use_bg_thread_pool: true,
|
||||||
stats: HashStats::default(),
|
stats: HashStats::default(),
|
||||||
check_hash: false,
|
check_hash: false,
|
||||||
accounts_cache_and_ancestors: None,
|
accounts_cache_and_ancestors: None,
|
||||||
|
@ -387,7 +373,6 @@ mod tests {
|
||||||
&exit,
|
&exit,
|
||||||
0,
|
0,
|
||||||
Some(&snapshot_config),
|
Some(&snapshot_config),
|
||||||
None,
|
|
||||||
ledger_path.path(),
|
ledger_path.path(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -5521,15 +5521,10 @@ impl AccountsDb {
|
||||||
..HashStats::default()
|
..HashStats::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
let thread_pool = if is_startup {
|
|
||||||
None
|
|
||||||
} else {
|
|
||||||
Some(&self.thread_pool_clean)
|
|
||||||
};
|
|
||||||
self.calculate_accounts_hash_without_index(&mut CalcAccountsHashConfig {
|
self.calculate_accounts_hash_without_index(&mut CalcAccountsHashConfig {
|
||||||
accounts_hash_cache_path: &self.accounts_hash_cache_path,
|
accounts_hash_cache_path: &self.accounts_hash_cache_path,
|
||||||
storages: &storages,
|
storages: &storages,
|
||||||
thread_pool,
|
use_bg_thread_pool: !is_startup,
|
||||||
stats: timings,
|
stats: timings,
|
||||||
check_hash,
|
check_hash,
|
||||||
accounts_cache_and_ancestors,
|
accounts_cache_and_ancestors,
|
||||||
|
@ -5735,7 +5730,7 @@ impl AccountsDb {
|
||||||
) -> Result<(Hash, u64), BankHashVerificationError> {
|
) -> Result<(Hash, u64), BankHashVerificationError> {
|
||||||
let (num_hash_scan_passes, bins_per_pass) =
|
let (num_hash_scan_passes, bins_per_pass) =
|
||||||
Self::bins_per_pass(config.num_hash_scan_passes);
|
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 scan_and_hash = move || {
|
||||||
let mut previous_pass = PreviousPass::default();
|
let mut previous_pass = PreviousPass::default();
|
||||||
let mut final_result = (Hash::default(), 0);
|
let mut final_result = (Hash::default(), 0);
|
||||||
|
@ -5780,8 +5775,8 @@ impl AccountsDb {
|
||||||
);
|
);
|
||||||
Ok(final_result)
|
Ok(final_result)
|
||||||
};
|
};
|
||||||
if let Some(thread_pool) = thread_pool {
|
if use_bg_thread_pool {
|
||||||
thread_pool.install(scan_and_hash)
|
self.thread_pool_clean.install(scan_and_hash)
|
||||||
} else {
|
} else {
|
||||||
scan_and_hash()
|
scan_and_hash()
|
||||||
}
|
}
|
||||||
|
@ -7910,7 +7905,7 @@ pub mod tests {
|
||||||
.calculate_accounts_hash_without_index(&mut CalcAccountsHashConfig {
|
.calculate_accounts_hash_without_index(&mut CalcAccountsHashConfig {
|
||||||
accounts_hash_cache_path: TempDir::new().unwrap().path(),
|
accounts_hash_cache_path: TempDir::new().unwrap().path(),
|
||||||
storages: &get_storage_refs(&storages),
|
storages: &get_storage_refs(&storages),
|
||||||
thread_pool: None,
|
use_bg_thread_pool: false,
|
||||||
stats: HashStats::default(),
|
stats: HashStats::default(),
|
||||||
check_hash: false,
|
check_hash: false,
|
||||||
accounts_cache_and_ancestors: None,
|
accounts_cache_and_ancestors: None,
|
||||||
|
@ -7937,7 +7932,7 @@ pub mod tests {
|
||||||
.calculate_accounts_hash_without_index(&mut CalcAccountsHashConfig {
|
.calculate_accounts_hash_without_index(&mut CalcAccountsHashConfig {
|
||||||
accounts_hash_cache_path: TempDir::new().unwrap().path(),
|
accounts_hash_cache_path: TempDir::new().unwrap().path(),
|
||||||
storages: &get_storage_refs(&storages),
|
storages: &get_storage_refs(&storages),
|
||||||
thread_pool: None,
|
use_bg_thread_pool: false,
|
||||||
stats: HashStats::default(),
|
stats: HashStats::default(),
|
||||||
check_hash: false,
|
check_hash: false,
|
||||||
accounts_cache_and_ancestors: None,
|
accounts_cache_and_ancestors: None,
|
||||||
|
|
|
@ -4,7 +4,7 @@ use {
|
||||||
sorted_storages::SortedStorages,
|
sorted_storages::SortedStorages,
|
||||||
},
|
},
|
||||||
log::*,
|
log::*,
|
||||||
rayon::{prelude::*, ThreadPool},
|
rayon::prelude::*,
|
||||||
solana_measure::measure::Measure,
|
solana_measure::measure::Measure,
|
||||||
solana_sdk::{
|
solana_sdk::{
|
||||||
hash::{Hash, Hasher},
|
hash::{Hash, Hasher},
|
||||||
|
@ -26,7 +26,7 @@ pub struct PreviousPass {
|
||||||
pub struct CalcAccountsHashConfig<'a> {
|
pub struct CalcAccountsHashConfig<'a> {
|
||||||
pub accounts_hash_cache_path: &'a Path,
|
pub accounts_hash_cache_path: &'a Path,
|
||||||
pub storages: &'a SortedStorages<'a>,
|
pub storages: &'a SortedStorages<'a>,
|
||||||
pub thread_pool: Option<&'a ThreadPool>,
|
pub use_bg_thread_pool: bool,
|
||||||
pub stats: HashStats,
|
pub stats: HashStats,
|
||||||
pub check_hash: bool,
|
pub check_hash: bool,
|
||||||
pub accounts_cache_and_ancestors: Option<(
|
pub accounts_cache_and_ancestors: Option<(
|
||||||
|
|
Loading…
Reference in New Issue