Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.
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
34 changes: 29 additions & 5 deletions runtime/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2424,6 +2424,7 @@ impl AccountsDb {
fn construct_candidate_clean_keys(
&self,
max_clean_root: Option<Slot>,
is_startup: bool,
last_full_snapshot_slot: Option<Slot>,
timings: &mut CleanKeyTimings,
) -> Vec<Pubkey> {
Expand All @@ -2441,11 +2442,33 @@ impl AccountsDb {
});
let dirty_stores_len = dirty_stores.len();
let pubkeys = DashSet::new();
timings.oldest_dirty_slot = max_slot_inclusive.saturating_add(1);
for (slot, store) in dirty_stores {
timings.oldest_dirty_slot = std::cmp::min(timings.oldest_dirty_slot, slot);
store.accounts.account_iter().for_each(|account| {
pubkeys.insert(account.meta.pubkey);
let mut dirty_store_routine = || {
let chunk_size = 1.max(dirty_stores_len.saturating_div(rayon::current_num_threads()));
let oldest_dirty_slots: Vec<u64> = dirty_stores
.par_chunks(chunk_size)
.map(|dirty_store_chunk| {
let mut oldest_dirty_slot = max_slot_inclusive.saturating_add(1);
dirty_store_chunk.iter().for_each(|(slot, store)| {
oldest_dirty_slot = oldest_dirty_slot.min(*slot);
store.accounts.account_iter().for_each(|account| {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

yes. This could be a page fault to iterate the append vec on disk. Makes sense we may want to request to page in multiple files in parallel as opposed to sequentially.

pubkeys.insert(account.meta.pubkey);
});
});
oldest_dirty_slot
})
.collect();
timings.oldest_dirty_slot = *oldest_dirty_slots
.iter()
.min()
.unwrap_or(&max_slot_inclusive.saturating_add(1));
};

if is_startup {
// Free to consume all the cores during startup
dirty_store_routine();
} else {
self.thread_pool_clean.install(|| {
dirty_store_routine();
});
}
trace!(
Expand Down Expand Up @@ -2533,6 +2556,7 @@ impl AccountsDb {
let mut key_timings = CleanKeyTimings::default();
let mut pubkeys = self.construct_candidate_clean_keys(
max_clean_root,
is_startup,
last_full_snapshot_slot,
&mut key_timings,
);
Expand Down