Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flush_slot_cache_with_clean() takes a single Slot #33413

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 9 additions & 14 deletions accounts-db/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6476,7 +6476,7 @@ impl AccountsDb {
let mut num_roots_flushed = 0;
for &root in cached_roots.iter().rev() {
if self
.flush_slot_cache_with_clean(&[root], should_flush_f.as_mut(), max_clean_root)
.flush_slot_cache_with_clean(root, should_flush_f.as_mut(), max_clean_root)
.is_some()
{
num_roots_flushed += 1;
Expand Down Expand Up @@ -6638,7 +6638,7 @@ impl AccountsDb {

/// flush all accounts in this slot
fn flush_slot_cache(&self, slot: Slot) -> Option<FlushStats> {
self.flush_slot_cache_with_clean(&[slot], None::<&mut fn(&_, &_) -> bool>, None)
self.flush_slot_cache_with_clean(slot, None::<&mut fn(&_, &_) -> bool>, None)
}

/// 1.13 and some 1.14 could produce legal snapshots with more than 1 append vec per slot.
Expand Down Expand Up @@ -6691,12 +6691,10 @@ impl AccountsDb {
/// accounts
fn flush_slot_cache_with_clean(
&self,
slots: &[Slot],
slot: Slot,
should_flush_f: Option<&mut impl FnMut(&Pubkey, &AccountSharedData) -> bool>,
max_clean_root: Option<Slot>,
) -> Option<FlushStats> {
assert_eq!(1, slots.len());
let slot = slots[0];
if self
.remove_unrooted_slots_synchronization
.slots_under_contention
Expand All @@ -6720,15 +6718,12 @@ impl AccountsDb {

// Nobody else should have been purging this slot, so should not have been removed
// from `self.remove_unrooted_slots_synchronization`.

slots.iter().for_each(|slot| {
assert!(self
.remove_unrooted_slots_synchronization
.slots_under_contention
.lock()
.unwrap()
.remove(slot));
});
assert!(self
.remove_unrooted_slots_synchronization
.slots_under_contention
.lock()
.unwrap()
.remove(&slot));

// Signal to any threads blocked on `remove_unrooted_slots(slot)` that we have finished
// flushing
Expand Down