flush_slot_cache takes [Slot] (#23865)

This commit is contained in:
Jeff Washington (jwash)
2022-03-24 10:24:36 -05:00
committed by GitHub
parent 9d3b17c635
commit f2aea3b7c7

View File

@@ -4735,7 +4735,7 @@ impl AccountsDb {
}; };
if self if self
.flush_slot_cache_with_clean(root, should_flush_f) .flush_slot_cache_with_clean(&[root], should_flush_f)
.is_some() .is_some()
{ {
num_roots_flushed += 1; num_roots_flushed += 1;
@@ -4842,7 +4842,7 @@ impl AccountsDb {
/// flush all accounts in this slot /// flush all accounts in this slot
fn flush_slot_cache(&self, slot: Slot) -> Option<FlushStats> { fn flush_slot_cache(&self, slot: Slot) -> Option<FlushStats> {
self.flush_slot_cache_with_clean(slot, None::<&mut fn(&_, &_) -> bool>) self.flush_slot_cache_with_clean(&[slot], None::<&mut fn(&_, &_) -> bool>)
} }
/// `should_flush_f` is an optional closure that determines whether a given /// `should_flush_f` is an optional closure that determines whether a given
@@ -4850,9 +4850,11 @@ impl AccountsDb {
/// accounts /// accounts
fn flush_slot_cache_with_clean( fn flush_slot_cache_with_clean(
&self, &self,
slot: Slot, slots: &[Slot],
should_flush_f: Option<&mut impl FnMut(&Pubkey, &AccountSharedData) -> bool>, should_flush_f: Option<&mut impl FnMut(&Pubkey, &AccountSharedData) -> bool>,
) -> Option<FlushStats> { ) -> Option<FlushStats> {
assert_eq!(1, slots.len());
let slot = slots[0];
if self if self
.remove_unrooted_slots_synchronization .remove_unrooted_slots_synchronization
.slots_under_contention .slots_under_contention
@@ -4876,12 +4878,15 @@ impl AccountsDb {
// Nobody else should have been purging this slot, so should not have been removed // Nobody else should have been purging this slot, so should not have been removed
// from `self.remove_unrooted_slots_synchronization`. // from `self.remove_unrooted_slots_synchronization`.
slots.iter().for_each(|slot| {
assert!(self assert!(self
.remove_unrooted_slots_synchronization .remove_unrooted_slots_synchronization
.slots_under_contention .slots_under_contention
.lock() .lock()
.unwrap() .unwrap()
.remove(&slot)); .remove(slot));
});
// Signal to any threads blocked on `remove_unrooted_slots(slot)` that we have finished // Signal to any threads blocked on `remove_unrooted_slots(slot)` that we have finished
// flushing // flushing