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

wip: check for all zeros on startup #2880

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Changes from 3 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
11 changes: 10 additions & 1 deletion accounts-db/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8836,7 +8836,7 @@ impl AccountsDb {

fn generate_index_for_slot(
&self,
storage: &AccountStorageEntry,
storage: &Arc<AccountStorageEntry>,
slot: Slot,
store_id: AccountsFileId,
rent_collector: &RentCollector,
Expand All @@ -8853,15 +8853,24 @@ impl AccountsDb {
let mut amount_to_top_off_rent = 0;
let mut stored_size_alive = 0;

let mut all_accounts_are_zero_lamports = true;

let (dirty_pubkeys, insert_time_us, mut generate_index_results) = {
let mut items_local = Vec::default();
storage.accounts.scan_index(|info| {
stored_size_alive += info.stored_size_aligned;
if info.index_info.lamports > 0 {
accounts_data_len += info.index_info.data_len;
all_accounts_are_zero_lamports = false;
}
items_local.push(info.index_info);
});
if all_accounts_are_zero_lamports {
// this whole slot can likely be marked dead and dropped. Clean has to determine that. There could be an older non-zero account for any of these zero lamport accounts.
self.dirty_stores.insert(slot, Arc::clone(storage));
self.accounts_index.add_uncleaned_roots([slot].into_iter());
self.shrink_candidate_slots.lock().unwrap().insert(slot);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know for sure we should do this. we may want to let clean calculate whether we can shrink or not. I suspect we don't want to add to shrink canddiate.

}
let items = items_local.into_iter().map(|info| {
if let Some(amount_to_top_off_rent_this_account) = Self::stats_for_rent_payers(
&info.pubkey,
Expand Down
Loading