Skip to content
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
45 changes: 32 additions & 13 deletions accounts-db/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ use {
active_stats::{ActiveStatItem, ActiveStats},
ancestors::Ancestors,
ancient_append_vecs::get_ancient_append_vec_capacity,
append_vec::{aligned_stored_size, STORE_META_OVERHEAD},
append_vec::{aligned_stored_size, IndexInfo, IndexInfoInner, STORE_META_OVERHEAD},
cache_hash_data::{CacheHashData, DeletionPolicy as CacheHashDeletionPolicy},
contains::Contains,
epoch_accounts_hash::EpochAccountsHashManager,
Expand Down Expand Up @@ -8046,7 +8046,8 @@ impl AccountsDb {

let (dirty_pubkeys, insert_time_us, mut generate_index_results) = {
let mut items_local = Vec::default();
storage.accounts.scan_index(|info| {
// this closure is the shared code when scanning the storage
let mut itemizer = |info: IndexInfo| {
stored_size_alive += info.stored_size_aligned;
if info.index_info.lamports > 0 {
accounts_data_len += info.index_info.data_len;
Expand All @@ -8056,8 +8057,36 @@ impl AccountsDb {
zero_lamport_pubkeys.push(info.index_info.pubkey);
}
items_local.push(info.index_info);
});
};

if secondary {
// WITH secondary indexes -- scan accounts WITH account data
storage.accounts.scan_accounts(|offset, account| {
let data_len = account.data.len() as u64;
let stored_size_aligned =
storage.accounts.calculate_stored_size(data_len as usize);
let info = IndexInfo {
stored_size_aligned,
index_info: IndexInfoInner {
offset,
pubkey: *account.pubkey,
lamports: account.lamports,
data_len,
rent_epoch: account.rent_epoch,
executable: account.executable,
Comment on lines +8075 to +8076
Copy link
Copy Markdown

@brooksprumo brooksprumo Jul 9, 2025

Choose a reason for hiding this comment

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

Note, these two fields (rent_epoch and executable) were removed from IndexInfoInner in master. They are not used here.

},
};
itemizer(info);
self.accounts_index.update_secondary_indexes(
account.pubkey,
&account,
&self.account_indexes,
);
});
} else {
// withOUT secondary indexes -- scan accounts withOUT account data
storage.accounts.scan_index(itemizer);
}
let items_len = items_local.len();
let items = items_local.into_iter().map(|info| {
if let Some(amount_to_top_off_rent_this_account) = Self::stats_for_rent_payers(
Expand Down Expand Up @@ -8085,16 +8114,6 @@ impl AccountsDb {
self.accounts_index
.insert_new_if_missing_into_primary_index(slot, items_len, items)
};
if secondary {
// scan storage a second time to update the secondary index
storage.accounts.scan_accounts(|_offset, stored_account| {
self.accounts_index.update_secondary_indexes(
stored_account.pubkey(),
&stored_account,
&self.account_indexes,
);
});
}

if let Some(duplicates_this_slot) = std::mem::take(&mut generate_index_results.duplicates) {
// there were duplicate pubkeys in this same slot
Expand Down
Loading