diff --git a/accounts-db/src/accounts_db.rs b/accounts-db/src/accounts_db.rs index 18bff15be909a2..343a13df9e49f4 100644 --- a/accounts-db/src/accounts_db.rs +++ b/accounts-db/src/accounts_db.rs @@ -1352,8 +1352,8 @@ impl StoreAccountsTiming { struct CleaningInfo { slot_list: SlotList, ref_count: u64, - /// True for pubkeys which contains zero accounts - contains_zero: bool, + /// True for pubkeys which can contain zero accounts + can_contain_zero: bool, } /// This is the return type of AccountsDb::construct_candidate_clean_keys. @@ -3149,12 +3149,12 @@ impl AccountsDb { match candidates_bin.entry(pubkey) { Entry::Occupied(occupied) => { if is_zero { - occupied.into_mut().contains_zero = true; + occupied.into_mut().can_contain_zero = true; } } Entry::Vacant(vacant) => { vacant.insert(CleaningInfo { - contains_zero: is_zero, + can_contain_zero: is_zero, ..Default::default() }); } @@ -3174,10 +3174,10 @@ impl AccountsDb { } oldest_dirty_slot = oldest_dirty_slot.min(*slot); - store.accounts.scan_accounts(|account| { - let pubkey = account.pubkey(); - let is_zero = account.is_zero_lamport(); - insert_candidate(*pubkey, is_zero); + store.accounts.scan_index(|index| { + let pubkey = index.index_info.pubkey; + let is_zero = index.index_info.lamports == 0; + insert_candidate(pubkey, is_zero); }); }); oldest_dirty_slot @@ -3460,7 +3460,11 @@ impl AccountsDb { }, None, false, - ScanFilter::All, + if candidate_info.can_contain_zero { + ScanFilter::All + } else { + self.scan_filter_for_shrinking + }, ); if should_purge { let reclaims_new = self.collect_reclaims( diff --git a/accounts-db/src/accounts_index.rs b/accounts-db/src/accounts_index.rs index f3f58979d6e242..a849d08af385f6 100644 --- a/accounts-db/src/accounts_index.rs +++ b/accounts-db/src/accounts_index.rs @@ -92,10 +92,6 @@ pub enum ScanFilter { /// Similar to `OnlyAbnormal but also check on-disk index to verify the /// entry on-disk is indeed normal. OnlyAbnormalWithVerify, - - // Scan in-memory first, then, depending on the condition, to decide whether - // to check on-disk index if it is not found in memory. - ConditionalOnDisk(bool), } #[derive(Debug, Clone, Copy, PartialEq, Eq)] @@ -1528,20 +1524,6 @@ impl + Into> AccountsIndex { }); } } - ScanFilter::ConditionalOnDisk(check_disk) => { - let found = lock - .as_ref() - .unwrap() - .get_only_in_mem(pubkey, false, |entry| { - internal_callback(entry); - entry.is_some() - }); - if !found && check_disk { - lock.as_ref() - .unwrap() - .get_internal(pubkey, internal_callback); - } - } } }); }