ancient shrink on its own cadence (#33712)
This commit is contained in:
parent
8bd0e4cd95
commit
d948e5bf69
|
@ -4403,11 +4403,12 @@ impl AccountsDb {
|
|||
|
||||
/// get a sorted list of slots older than an epoch
|
||||
/// squash those slots into ancient append vecs
|
||||
fn shrink_ancient_slots(&self, oldest_non_ancient_slot: Slot) {
|
||||
pub fn shrink_ancient_slots(&self, epoch_schedule: &EpochSchedule) {
|
||||
if self.ancient_append_vec_offset.is_none() {
|
||||
return;
|
||||
}
|
||||
|
||||
let oldest_non_ancient_slot = self.get_oldest_non_ancient_slot(epoch_schedule);
|
||||
let can_randomly_shrink = true;
|
||||
let sorted_slots = self.get_sorted_potential_ancient_slots(oldest_non_ancient_slot);
|
||||
if self.create_ancient_storage == CreateAncientStorage::Append {
|
||||
|
@ -4752,10 +4753,6 @@ impl AccountsDb {
|
|||
|
||||
pub fn shrink_candidate_slots(&self, epoch_schedule: &EpochSchedule) -> usize {
|
||||
let oldest_non_ancient_slot = self.get_oldest_non_ancient_slot(epoch_schedule);
|
||||
if !self.shrink_candidate_slots.lock().unwrap().is_empty() {
|
||||
// this can affect 'shrink_candidate_slots', so don't 'take' it until after this completes
|
||||
self.shrink_ancient_slots(oldest_non_ancient_slot);
|
||||
}
|
||||
|
||||
let shrink_candidates_slots =
|
||||
std::mem::take(&mut *self.shrink_candidate_slots.lock().unwrap());
|
||||
|
|
|
@ -21,7 +21,7 @@ use {
|
|||
solana_accounts_db::{
|
||||
accounts_db::CalcAccountsHashDataSource, accounts_hash::CalcAccountsHashConfig,
|
||||
},
|
||||
solana_measure::measure::Measure,
|
||||
solana_measure::{measure::Measure, measure_us},
|
||||
solana_sdk::clock::{BankId, Slot},
|
||||
stats::StatsManager,
|
||||
std::{
|
||||
|
@ -383,6 +383,8 @@ impl SnapshotRequestHandler {
|
|||
snapshot_root_bank.clean_accounts(*last_full_snapshot_slot);
|
||||
clean_time.stop();
|
||||
|
||||
let (_, shrink_ancient_time_us) = measure_us!(snapshot_root_bank.shrink_ancient_slots());
|
||||
|
||||
let mut shrink_time = Measure::start("shrink_time");
|
||||
snapshot_root_bank.shrink_candidate_slots();
|
||||
shrink_time.stop();
|
||||
|
@ -464,6 +466,7 @@ impl SnapshotRequestHandler {
|
|||
("snapshot_time", snapshot_time.as_us(), i64),
|
||||
("total_us", total_time.as_us(), i64),
|
||||
("non_snapshot_time_us", non_snapshot_time_us, i64),
|
||||
("shrink_ancient_time_us", shrink_ancient_time_us, i64),
|
||||
);
|
||||
Ok(snapshot_root_bank.block_height())
|
||||
}
|
||||
|
@ -705,6 +708,7 @@ impl AccountsBackgroundService {
|
|||
bank.force_flush_accounts_cache();
|
||||
bank.clean_accounts(last_full_snapshot_slot);
|
||||
last_cleaned_block_height = bank.block_height();
|
||||
bank.shrink_ancient_slots();
|
||||
}
|
||||
bank.shrink_candidate_slots();
|
||||
}
|
||||
|
|
|
@ -7952,6 +7952,13 @@ impl Bank {
|
|||
.shrink_candidate_slots(self.epoch_schedule())
|
||||
}
|
||||
|
||||
pub(crate) fn shrink_ancient_slots(&self) {
|
||||
self.rc
|
||||
.accounts
|
||||
.accounts_db
|
||||
.shrink_ancient_slots(self.epoch_schedule())
|
||||
}
|
||||
|
||||
pub fn no_overflow_rent_distribution_enabled(&self) -> bool {
|
||||
self.feature_set
|
||||
.is_active(&feature_set::no_overflow_rent_distribution::id())
|
||||
|
|
Loading…
Reference in New Issue