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