Skip to content

Commit

Permalink
Dynamic chunk size
Browse files Browse the repository at this point in the history
  • Loading branch information
bw-solana committed Aug 15, 2022
1 parent 4e62730 commit 35b22a3
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions runtime/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2448,9 +2448,10 @@ impl AccountsDb {
});
let dirty_stores_len = dirty_stores.len();
let pubkeys = DashSet::new();
let mut dirty_store_routine = || {
let mut dirty_store_routine = |thread_count| {
let chunk_size = 1.max(dirty_stores_len.saturating_div(thread_count));
let oldest_dirty_slots: Vec<u64> = dirty_stores
.par_chunks(4096)
.par_chunks(chunk_size)
.map(|dirty_store_chunk| {
let mut oldest_dirty_slot = max_slot.saturating_add(1);
dirty_store_chunk.iter().for_each(|(slot, store)| {
Expand All @@ -2469,9 +2470,11 @@ impl AccountsDb {
};

if is_startup {
dirty_store_routine();
dirty_store_routine(rayon::current_num_threads());
} else {
self.thread_pool_clean.install(dirty_store_routine);
self.thread_pool_clean.install(|| {
dirty_store_routine(quarter_thread_count());
});
}
trace!(
"dirty_stores.len: {} pubkeys.len: {}",
Expand Down

0 comments on commit 35b22a3

Please sign in to comment.