improve clean acct idx calls (#26320)

This commit is contained in:
Jeff Washington (jwash) 2022-07-07 15:50:12 -05:00 committed by GitHub
parent b582e4ce0f
commit ee0a54ce80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 4 deletions

View File

@ -7358,15 +7358,19 @@ impl AccountsDb {
let mut measure = Measure::start("unref_from_storage");
if let Some(purged_stored_account_slots) = purged_stored_account_slots {
let len = purged_stored_account_slots.len();
// we could build a higher level function in accounts_index to group by bin
const BATCH_SIZE: usize = 10_000;
let batches = 1 + (len / BATCH_SIZE);
self.thread_pool_clean.install(|| {
(0..batches).into_par_iter().for_each(|batch| {
let skip = batch * BATCH_SIZE;
for (_slot, pubkey) in purged_slot_pubkeys.iter().skip(skip).take(BATCH_SIZE) {
self.accounts_index.unref_from_storage(pubkey);
}
self.accounts_index.scan(
purged_slot_pubkeys
.iter()
.skip(skip)
.take(BATCH_SIZE)
.map(|(_slot, pubkey)| pubkey),
|_pubkey, _slots_refs| AccountsIndexScanResult::Unref,
)
})
});
for (slot, pubkey) in purged_slot_pubkeys {