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
21 changes: 17 additions & 4 deletions accounts-db/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5455,14 +5455,17 @@ impl AccountsDb {
}
}

/// Updates the accounts index with the given `infos` and `accounts`.
/// Returns a vector of `SlotList<AccountInfo>` containing the reclaims for each batch processed.
/// The element of the returned vector is guaranteed to be non-empty.
fn update_index<'a>(
&self,
infos: Vec<AccountInfo>,
accounts: &impl StorableAccounts<'a>,
reclaim: UpsertReclaim,
update_index_thread_selection: UpdateIndexThreadSelection,
thread_pool: &ThreadPool,
) -> ReclaimsSlotList<AccountInfo> {
) -> Vec<ReclaimsSlotList<AccountInfo>> {
Comment thread
brooksprumo marked this conversation as resolved.
let target_slot = accounts.target_slot();
let len = std::cmp::min(accounts.len(), infos.len());

Expand Down Expand Up @@ -5512,11 +5515,17 @@ impl AccountsDb {
let end = std::cmp::min(start + chunk_size, len);
update(start, end)
})
.flatten()
.filter(|reclaims| !reclaims.is_empty())
.collect()
})
} else {
update(0, len)
let reclaims = update(0, len);
Comment thread
HaoranYi marked this conversation as resolved.
if reclaims.is_empty() {
// If no reclaims, return an empty vector
vec![]
} else {
vec![reclaims]
}
}
}

Expand Down Expand Up @@ -5990,11 +5999,15 @@ impl AccountsDb {
// If there are any reclaims then they should be handled. Reclaims affect
// all storages, and may result in the removal of dead storages.
let mut handle_reclaims_elapsed = 0;

// since reclaims only contains non-empty SlotList<AccountInfo>, we
// should skip handle_reclaims only when reclaims is empty. No need to
// check the elements of reclaims are empty.
if !reclaims.is_empty() {
let purge_stats = PurgeStats::default();
let mut handle_reclaims_time = Measure::start("handle_reclaims");
self.handle_reclaims(
reclaims.iter(),
reclaims.iter().flatten(),
Comment thread
HaoranYi marked this conversation as resolved.
None,
&HashSet::default(),
HandleReclaims::ProcessDeadSlots(&purge_stats),
Expand Down
Loading