Add jitter to cleanup to prevent all nodes cleaning at the same time (#10936)
This commit is contained in:
parent
1f5070e569
commit
631f051c68
|
@ -2,6 +2,7 @@
|
|||
//
|
||||
// This can be expensive since we have to walk the append vecs being cleaned up.
|
||||
|
||||
use rand::{thread_rng, Rng};
|
||||
use solana_runtime::bank_forks::BankForks;
|
||||
use std::sync::{
|
||||
atomic::{AtomicBool, Ordering},
|
||||
|
@ -39,7 +40,9 @@ impl AccountsBackgroundService {
|
|||
consumed_budget = bank
|
||||
.process_stale_slot_with_budget(consumed_budget, SHRUNKEN_ACCOUNT_PER_INTERVAL);
|
||||
|
||||
if bank.block_height() - last_cleaned_slot > CLEAN_INTERVAL_SLOTS {
|
||||
if bank.block_height() - last_cleaned_slot
|
||||
> (CLEAN_INTERVAL_SLOTS + thread_rng().gen_range(0, 10))
|
||||
{
|
||||
bank.clean_accounts();
|
||||
last_cleaned_slot = bank.block_height();
|
||||
}
|
||||
|
|
|
@ -721,7 +721,7 @@ impl AccountsDB {
|
|||
|
||||
let mut reclaims_time = Measure::start("reclaims");
|
||||
// Recalculate reclaims with new purge set
|
||||
let purges_key_to_slot_set: Vec<_> = purges
|
||||
let pubkey_to_slot_set: Vec<_> = purges
|
||||
.into_iter()
|
||||
.map(|(key, (slots_list, _ref_count))| {
|
||||
(
|
||||
|
@ -733,7 +733,7 @@ impl AccountsDB {
|
|||
let accounts_index = self.accounts_index.read().unwrap();
|
||||
let mut reclaims = Vec::new();
|
||||
let mut dead_keys = Vec::new();
|
||||
for (pubkey, slots_set) in purges_key_to_slot_set {
|
||||
for (pubkey, slots_set) in pubkey_to_slot_set {
|
||||
let (new_reclaims, is_empty) = accounts_index.purge_exact(&pubkey, slots_set);
|
||||
if is_empty {
|
||||
dead_keys.push(pubkey);
|
||||
|
|
Loading…
Reference in New Issue