Skip to content

Commit

Permalink
Refactors cached_frozen_slots() (solana-labs#3644)
Browse files Browse the repository at this point in the history
  • Loading branch information
brooksprumo authored Nov 14, 2024
1 parent 693d0e8 commit 91ccab3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
13 changes: 3 additions & 10 deletions accounts-db/src/accounts_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,20 +259,13 @@ impl AccountsCache {
}

pub fn cached_frozen_slots(&self) -> Vec<Slot> {
let mut slots: Vec<_> = self
.cache
self.cache
.iter()
.filter_map(|item| {
let (slot, slot_cache) = item.pair();
if slot_cache.is_frozen() {
Some(*slot)
} else {
None
}
slot_cache.is_frozen().then_some(*slot)
})
.collect();
slots.sort_unstable();
slots
.collect()
}

pub fn contains(&self, slot: Slot) -> bool {
Expand Down
3 changes: 2 additions & 1 deletion accounts-db/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6172,7 +6172,8 @@ impl AccountsDb {
let mut unflushable_unrooted_slot_count = 0;
let max_flushed_root = self.accounts_cache.fetch_max_flush_root();
if self.should_aggressively_flush_cache() {
let old_slots = self.accounts_cache.cached_frozen_slots();
let mut old_slots = self.accounts_cache.cached_frozen_slots();
old_slots.sort_unstable();
excess_slot_count = old_slots.len();
let mut flush_stats = FlushStats::default();
old_slots.into_iter().for_each(|old_slot| {
Expand Down

0 comments on commit 91ccab3

Please sign in to comment.