Lower priority for hashing threads. (#14043)

This commit is contained in:
sakridge 2020-12-10 12:26:47 -08:00 committed by GitHub
parent 409fe3bca1
commit 68109a46e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 85 additions and 77 deletions

View File

@ -766,7 +766,9 @@ impl AccountsDB {
.cloned() .cloned()
.collect(); .collect();
// parallel scan the index. // parallel scan the index.
let (mut purges, purges_in_root) = pubkeys let (mut purges, purges_in_root) = {
self.thread_pool_clean.install(|| {
pubkeys
.par_chunks(4096) .par_chunks(4096)
.map(|pubkeys: &[Pubkey]| { .map(|pubkeys: &[Pubkey]| {
let mut purges_in_root = Vec::new(); let mut purges_in_root = Vec::new();
@ -808,7 +810,9 @@ impl AccountsDB {
m1.1.extend(m2.1); m1.1.extend(m2.1);
m1 m1
}, },
); )
})
};
accounts_scan.stop(); accounts_scan.stop();
let mut clean_old_rooted = Measure::start("clean_old_roots"); let mut clean_old_rooted = Measure::start("clean_old_roots");
@ -2258,8 +2262,9 @@ impl AccountsDB {
.cloned() .cloned()
.collect(); .collect();
let mismatch_found = AtomicU64::new(0); let mismatch_found = AtomicU64::new(0);
let hashes: Vec<(Pubkey, Hash, u64)> = keys let hashes: Vec<(Pubkey, Hash, u64)> = {
.par_iter() self.thread_pool_clean.install(|| {
keys.par_iter()
.filter_map(|pubkey| { .filter_map(|pubkey| {
if let Some((lock, index)) = if let Some((lock, index)) =
self.accounts_index.get(pubkey, Some(ancestors), Some(slot)) self.accounts_index.get(pubkey, Some(ancestors), Some(slot))
@ -2269,7 +2274,8 @@ impl AccountsDB {
self.storage self.storage
.get_account_storage_entry(*slot, account_info.store_id) .get_account_storage_entry(*slot, account_info.store_id)
.and_then(|store| { .and_then(|store| {
let account = store.accounts.get_account(account_info.offset)?.0; let account =
store.accounts.get_account(account_info.offset)?.0;
let balance = Self::account_balance_for_capitalization( let balance = Self::account_balance_for_capitalization(
account_info.lamports, account_info.lamports,
&account.account_meta.owner, &account.account_meta.owner,
@ -2280,9 +2286,9 @@ impl AccountsDB {
let hash = Self::hash_stored_account( let hash = Self::hash_stored_account(
*slot, *slot,
&account, &account,
&self &self.cluster_type.expect(
.cluster_type "Cluster type must be set at initialization",
.expect("Cluster type must be set at initialization"), ),
); );
if hash != *account.hash { if hash != *account.hash {
mismatch_found.fetch_add(1, Ordering::Relaxed); mismatch_found.fetch_add(1, Ordering::Relaxed);
@ -2299,7 +2305,9 @@ impl AccountsDB {
None None
} }
}) })
.collect(); .collect()
})
};
if mismatch_found.load(Ordering::Relaxed) > 0 { if mismatch_found.load(Ordering::Relaxed) > 0 {
warn!( warn!(
"{} mismatched account hash(es) found", "{} mismatched account hash(es) found",