Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
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
35 changes: 24 additions & 11 deletions runtime/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,13 @@ pub struct ErrorCounters {
pub invalid_writable_account: usize,
}

#[derive(Debug, Default, Clone, Copy)]
struct SlotIndexGenerationInfo {
insert_time_us: u64,
num_accounts: u64,
num_accounts_rent_exempt: u64,
}

#[derive(Default, Debug)]
struct GenerateIndexTimings {
pub index_time: u64,
Expand Down Expand Up @@ -6657,21 +6664,20 @@ impl AccountsDb {
accounts_map
}

/// return time_us, # accts rent exempt, total # accts
fn generate_index_for_slot<'a>(
&self,
accounts_map: GenerateIndexAccountsMap<'a>,
slot: &Slot,
rent_collector: &RentCollector,
) -> (u64, u64, u64) {
) -> SlotIndexGenerationInfo {
if accounts_map.is_empty() {
return (0, 0, 0);
return SlotIndexGenerationInfo::default();
}

let secondary = !self.account_indexes.is_empty();

let mut rent_exempt = 0;
let len = accounts_map.len();
let mut num_accounts_rent_exempt = 0;
let num_accounts = accounts_map.len();
let items = accounts_map.into_iter().map(
|(
pubkey,
Expand All @@ -6694,7 +6700,7 @@ impl AccountsDb {
let (_rent_due, exempt) = rent_collector.get_rent_due(&stored_account);
exempt
} {
rent_exempt += 1;
num_accounts_rent_exempt += 1;
}

(
Expand All @@ -6709,17 +6715,21 @@ impl AccountsDb {
},
);

let (dirty_pubkeys, insert_us) = self
let (dirty_pubkeys, insert_time_us) = self
.accounts_index
.insert_new_if_missing_into_primary_index(*slot, len, items);
.insert_new_if_missing_into_primary_index(*slot, num_accounts, items);

// dirty_pubkeys will contain a pubkey if an item has multiple rooted entries for
// a given pubkey. If there is just a single item, there is no cleaning to
// be done on that pubkey. Use only those pubkeys with multiple updates.
if !dirty_pubkeys.is_empty() {
self.uncleaned_pubkeys.insert(*slot, dirty_pubkeys);
}
(insert_us, rent_exempt, len as u64)
SlotIndexGenerationInfo {
insert_time_us,
num_accounts: num_accounts as u64,
num_accounts_rent_exempt,
}
}

fn filler_unique_id_bytes() -> usize {
Expand Down Expand Up @@ -6915,8 +6925,11 @@ impl AccountsDb {

let insert_us = if pass == 0 {
// generate index
let (insert_us, rent_exempt_this_slot, total_this_slot) =
self.generate_index_for_slot(accounts_map, slot, &rent_collector);
let SlotIndexGenerationInfo {
insert_time_us: insert_us,
num_accounts: total_this_slot,
num_accounts_rent_exempt: rent_exempt_this_slot,
} = self.generate_index_for_slot(accounts_map, slot, &rent_collector);
rent_exempt.fetch_add(rent_exempt_this_slot, Ordering::Relaxed);
total_duplicates.fetch_add(total_this_slot, Ordering::Relaxed);
insert_us
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/serde_snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ where
})
.unwrap();

accounts_db.generate_index(
let _ = accounts_db.generate_index(
limit_load_slot_count_from_snapshot,
verify_index,
genesis_config,
Expand Down