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
43 changes: 30 additions & 13 deletions accounts-db/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,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 @@ -7819,7 +7819,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 @@ -7829,8 +7830,34 @@ 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,
},
};
itemizer(info);
self.accounts_index.update_secondary_indexes(
account.pubkey,
&account,
&self.account_indexes,
);
Comment thread
t-nelson marked this conversation as resolved.
});
} 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| {
(
Expand All @@ -7844,16 +7871,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