Add jitter to cleanup to prevent all nodes cleaning at the same time (#10936)

This commit is contained in:
sakridge
2020-07-10 11:54:45 -07:00
committed by GitHub
parent 1f5070e569
commit 631f051c68
2 changed files with 6 additions and 3 deletions

View File

@ -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();
}