do_shrink_slot_stores -> do_shrink_slot_store (#29552)

This commit is contained in:
Jeff Washington (jwash) 2023-01-06 11:23:32 -06:00 committed by GitHub
parent 39dc034c05
commit 3fc4015a4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 10 deletions

View File

@ -3834,13 +3834,14 @@ impl AccountsDb {
self.drop_or_recycle_stores(dead_storages, stats); self.drop_or_recycle_stores(dead_storages, stats);
} }
fn do_shrink_slot_stores<'a, I>(&'a self, slot: Slot, stores: I) -> usize fn do_shrink_slot_store(&self, slot: Slot, store: &Arc<AccountStorageEntry>) -> usize {
where
I: Iterator<Item = &'a Arc<AccountStorageEntry>>,
{
let mut stored_accounts = Vec::default(); let mut stored_accounts = Vec::default();
debug!("do_shrink_slot_stores: slot: {}", slot); debug!("do_shrink_slot_store: slot: {}", slot);
let shrink_collect = self.shrink_collect(stores, &mut stored_accounts, &self.shrink_stats); let shrink_collect = self.shrink_collect(
std::iter::once(store),
&mut stored_accounts,
&self.shrink_stats,
);
// This shouldn't happen if alive_bytes/approx_stored_count are accurate // This shouldn't happen if alive_bytes/approx_stored_count are accurate
if Self::should_not_shrink( if Self::should_not_shrink(
@ -4055,7 +4056,7 @@ impl AccountsDb {
if !Self::is_shrinking_productive(slot, &store) { if !Self::is_shrinking_productive(slot, &store) {
return 0; return 0;
} }
self.do_shrink_slot_stores(slot, std::iter::once(&store)) self.do_shrink_slot_store(slot, &store)
} else { } else {
0 0
} }
@ -4602,7 +4603,7 @@ impl AccountsDb {
.into_par_iter() .into_par_iter()
.for_each(|(slot, slot_shrink_candidate)| { .for_each(|(slot, slot_shrink_candidate)| {
let mut measure = Measure::start("shrink_candidate_slots-ms"); let mut measure = Measure::start("shrink_candidate_slots-ms");
self.do_shrink_slot_stores(slot, std::iter::once(&slot_shrink_candidate)); self.do_shrink_slot_store(slot, &slot_shrink_candidate);
measure.stop(); measure.stop();
inc_new_counter_info!("shrink_candidate_slots-ms", measure.as_ms() as usize); inc_new_counter_info!("shrink_candidate_slots-ms", measure.as_ms() as usize);
}); });
@ -4978,7 +4979,7 @@ impl AccountsDb {
// //
// Shrinker | Accessed data source for stored // Shrinker | Accessed data source for stored
// -------------------------------------+---------------------------------- // -------------------------------------+----------------------------------
// S1 do_shrink_slot_stores() | N/A // S1 do_shrink_slot_store() | N/A
// | | // | |
// V | // V |
// S2 store_accounts_frozen()/ | map of stores (creates new entry) // S2 store_accounts_frozen()/ | map of stores (creates new entry)
@ -4989,7 +4990,7 @@ impl AccountsDb {
// update_index() | (replaces existing store_id, offset in stores) // update_index() | (replaces existing store_id, offset in stores)
// | | // | |
// V | // V |
// S4 do_shrink_slot_stores()/ | map of stores (removes old entry) // S4 do_shrink_slot_store()/ | map of stores (removes old entry)
// dead_storages // dead_storages
// //
// Remarks for shrinker: So, for any reading operations, it's a race condition // Remarks for shrinker: So, for any reading operations, it's a race condition