Skip to content

Commit

Permalink
reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
HaoranYi committed Sep 10, 2024
1 parent e180029 commit f557e79
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 27 deletions.
22 changes: 13 additions & 9 deletions accounts-db/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1352,8 +1352,8 @@ impl StoreAccountsTiming {
struct CleaningInfo {
slot_list: SlotList<AccountInfo>,
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.
Expand Down Expand Up @@ -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()
});
}
Expand All @@ -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
Expand Down Expand Up @@ -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(
Expand Down
18 changes: 0 additions & 18 deletions accounts-db/src/accounts_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -1528,20 +1524,6 @@ impl<T: IndexValue, U: DiskIndexValue + From<T> + Into<T>> AccountsIndex<T, U> {
});
}
}
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);
}
}
}
});
}
Expand Down

0 comments on commit f557e79

Please sign in to comment.