diff --git a/runtime/src/accounts_db.rs b/runtime/src/accounts_db.rs index db921b02dd8e02..66dd76f8a9a3a3 100644 --- a/runtime/src/accounts_db.rs +++ b/runtime/src/accounts_db.rs @@ -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 = 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)| { @@ -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: {}",