remove process_stale_slot_with_budget (#29236)
This commit is contained in:
parent
c8e7c706df
commit
b779134020
|
@ -32,9 +32,6 @@ use {
|
||||||
};
|
};
|
||||||
|
|
||||||
const INTERVAL_MS: u64 = 100;
|
const INTERVAL_MS: u64 = 100;
|
||||||
const SHRUNKEN_ACCOUNT_PER_SEC: usize = 250;
|
|
||||||
const SHRUNKEN_ACCOUNT_PER_INTERVAL: usize =
|
|
||||||
SHRUNKEN_ACCOUNT_PER_SEC / (1000 / INTERVAL_MS as usize);
|
|
||||||
const CLEAN_INTERVAL_BLOCKS: u64 = 100;
|
const CLEAN_INTERVAL_BLOCKS: u64 = 100;
|
||||||
|
|
||||||
// This value is chosen to spread the dropping cost over 3 expiration checks
|
// This value is chosen to spread the dropping cost over 3 expiration checks
|
||||||
|
@ -264,7 +261,7 @@ impl SnapshotRequestHandler {
|
||||||
|
|
||||||
fn handle_snapshot_request(
|
fn handle_snapshot_request(
|
||||||
&self,
|
&self,
|
||||||
accounts_db_caching_enabled: bool,
|
_accounts_db_caching_enabled: bool,
|
||||||
test_hash_calculation: bool,
|
test_hash_calculation: bool,
|
||||||
non_snapshot_time_us: u128,
|
non_snapshot_time_us: u128,
|
||||||
last_full_snapshot_slot: &mut Option<Slot>,
|
last_full_snapshot_slot: &mut Option<Slot>,
|
||||||
|
@ -300,12 +297,6 @@ impl SnapshotRequestHandler {
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
|
||||||
let mut shrink_time = Measure::start("shrink_time");
|
|
||||||
if !accounts_db_caching_enabled {
|
|
||||||
snapshot_root_bank.process_stale_slot_with_budget(0, SHRUNKEN_ACCOUNT_PER_INTERVAL);
|
|
||||||
}
|
|
||||||
shrink_time.stop();
|
|
||||||
|
|
||||||
let mut flush_accounts_cache_time = Measure::start("flush_accounts_cache_time");
|
let mut flush_accounts_cache_time = Measure::start("flush_accounts_cache_time");
|
||||||
// Forced cache flushing MUST flush all roots <= snapshot_root_bank.slot().
|
// Forced cache flushing MUST flush all roots <= snapshot_root_bank.slot().
|
||||||
// That's because `snapshot_root_bank.slot()` must be root at this point,
|
// That's because `snapshot_root_bank.slot()` must be root at this point,
|
||||||
|
@ -355,11 +346,9 @@ impl SnapshotRequestHandler {
|
||||||
snapshot_root_bank.clean_accounts(*last_full_snapshot_slot);
|
snapshot_root_bank.clean_accounts(*last_full_snapshot_slot);
|
||||||
clean_time.stop();
|
clean_time.stop();
|
||||||
|
|
||||||
if accounts_db_caching_enabled {
|
let mut shrink_time = Measure::start("shrink_time");
|
||||||
shrink_time = Measure::start("shrink_time");
|
snapshot_root_bank.shrink_candidate_slots();
|
||||||
snapshot_root_bank.shrink_candidate_slots();
|
shrink_time.stop();
|
||||||
shrink_time.stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Snapshot the bank and send over an accounts package
|
// Snapshot the bank and send over an accounts package
|
||||||
let mut snapshot_time = Measure::start("snapshot_time");
|
let mut snapshot_time = Measure::start("snapshot_time");
|
||||||
|
@ -541,10 +530,8 @@ impl AccountsBackgroundService {
|
||||||
test_hash_calculation: bool,
|
test_hash_calculation: bool,
|
||||||
mut last_full_snapshot_slot: Option<Slot>,
|
mut last_full_snapshot_slot: Option<Slot>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let accounts_db_caching_enabled = true;
|
|
||||||
info!("AccountsBackgroundService active");
|
info!("AccountsBackgroundService active");
|
||||||
let exit = exit.clone();
|
let exit = exit.clone();
|
||||||
let mut consumed_budget = 0;
|
|
||||||
let mut last_cleaned_block_height = 0;
|
let mut last_cleaned_block_height = 0;
|
||||||
let mut removed_slots_count = 0;
|
let mut removed_slots_count = 0;
|
||||||
let mut total_remove_slots_time = 0;
|
let mut total_remove_slots_time = 0;
|
||||||
|
@ -633,19 +620,7 @@ impl AccountsBackgroundService {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if accounts_db_caching_enabled {
|
bank.shrink_candidate_slots();
|
||||||
bank.shrink_candidate_slots();
|
|
||||||
} else {
|
|
||||||
// under sustained writes, shrink can lag behind so cap to
|
|
||||||
// SHRUNKEN_ACCOUNT_PER_INTERVAL (which is based on INTERVAL_MS,
|
|
||||||
// which in turn roughly associated block time)
|
|
||||||
consumed_budget = bank
|
|
||||||
.process_stale_slot_with_budget(
|
|
||||||
consumed_budget,
|
|
||||||
SHRUNKEN_ACCOUNT_PER_INTERVAL,
|
|
||||||
)
|
|
||||||
.min(SHRUNKEN_ACCOUNT_PER_INTERVAL);
|
|
||||||
}
|
|
||||||
if bank.block_height() - last_cleaned_block_height
|
if bank.block_height() - last_cleaned_block_height
|
||||||
> (CLEAN_INTERVAL_BLOCKS + thread_rng().gen_range(0, 10))
|
> (CLEAN_INTERVAL_BLOCKS + thread_rng().gen_range(0, 10))
|
||||||
{
|
{
|
||||||
|
|
|
@ -7378,16 +7378,6 @@ impl Bank {
|
||||||
self.rc.accounts.accounts_db.print_accounts_stats("");
|
self.rc.accounts.accounts_db.print_accounts_stats("");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This is part of the code path executed when the write cache is disabled.
|
|
||||||
/// It is no longer possible to disable the write cache.
|
|
||||||
pub fn process_stale_slot_with_budget(
|
|
||||||
&self,
|
|
||||||
mut _consumed_budget: usize,
|
|
||||||
_budget_recovery_delta: usize,
|
|
||||||
) -> usize {
|
|
||||||
unimplemented!("");
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn bank_tranaction_count_fix_enabled(&self) -> bool {
|
pub fn bank_tranaction_count_fix_enabled(&self) -> bool {
|
||||||
self.feature_set
|
self.feature_set
|
||||||
.is_active(&feature_set::bank_tranaction_count_fix::id())
|
.is_active(&feature_set::bank_tranaction_count_fix::id())
|
||||||
|
@ -14864,63 +14854,6 @@ pub(crate) mod tests {
|
||||||
assert_eq!(alive_counts, vec![11, 1, 7]);
|
assert_eq!(alive_counts, vec![11, 1, 7]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// process_stale_slot_with_budget is no longer called. We'll remove this test when we remove the function
|
|
||||||
#[test]
|
|
||||||
#[ignore] // this test only works when not using the write cache
|
|
||||||
fn test_process_stale_slot_with_budget() {
|
|
||||||
solana_logger::setup();
|
|
||||||
let pubkey1 = solana_sdk::pubkey::new_rand();
|
|
||||||
let pubkey2 = solana_sdk::pubkey::new_rand();
|
|
||||||
|
|
||||||
// this test only tests non-write cache code
|
|
||||||
// Tests need to default to use write cache by default for all tests.
|
|
||||||
// Once that happens, the code this test tests can be deleted, along with this test.
|
|
||||||
let (genesis_config, _mint_keypair) = create_genesis_config(1_000_000_000);
|
|
||||||
let mut bank = Arc::new(Bank::new_with_config_for_tests(
|
|
||||||
&genesis_config,
|
|
||||||
AccountSecondaryIndexes::default(),
|
|
||||||
AccountShrinkThreshold::default(),
|
|
||||||
));
|
|
||||||
|
|
||||||
bank.restore_old_behavior_for_fragile_tests();
|
|
||||||
assert_eq!(bank.process_stale_slot_with_budget(0, 0), 0);
|
|
||||||
assert_eq!(bank.process_stale_slot_with_budget(133, 0), 133);
|
|
||||||
|
|
||||||
assert_eq!(bank.process_stale_slot_with_budget(0, 100), 0);
|
|
||||||
assert_eq!(bank.process_stale_slot_with_budget(33, 100), 0);
|
|
||||||
assert_eq!(bank.process_stale_slot_with_budget(133, 100), 33);
|
|
||||||
|
|
||||||
goto_end_of_slot(Arc::<Bank>::get_mut(&mut bank).unwrap());
|
|
||||||
|
|
||||||
bank.squash();
|
|
||||||
|
|
||||||
let some_lamports = 123;
|
|
||||||
let mut bank = Arc::new(new_from_parent(&bank));
|
|
||||||
bank.deposit(&pubkey1, some_lamports).unwrap();
|
|
||||||
bank.deposit(&pubkey2, some_lamports).unwrap();
|
|
||||||
|
|
||||||
goto_end_of_slot(Arc::<Bank>::get_mut(&mut bank).unwrap());
|
|
||||||
|
|
||||||
let mut bank = Arc::new(new_from_parent(&bank));
|
|
||||||
bank.deposit(&pubkey1, some_lamports).unwrap();
|
|
||||||
|
|
||||||
goto_end_of_slot(Arc::<Bank>::get_mut(&mut bank).unwrap());
|
|
||||||
|
|
||||||
bank.squash();
|
|
||||||
bank.clean_accounts_for_tests();
|
|
||||||
let force_to_return_alive_account = 0;
|
|
||||||
assert_eq!(
|
|
||||||
bank.process_stale_slot_with_budget(22, force_to_return_alive_account),
|
|
||||||
22
|
|
||||||
);
|
|
||||||
|
|
||||||
let consumed_budgets: usize = (0..3)
|
|
||||||
.map(|_| bank.process_stale_slot_with_budget(0, force_to_return_alive_account))
|
|
||||||
.sum();
|
|
||||||
// consumed_budgets represents the count of alive accounts in the three slots 0,1,2
|
|
||||||
assert_eq!(consumed_budgets, 12);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_add_builtin_no_overwrite() {
|
fn test_add_builtin_no_overwrite() {
|
||||||
#[allow(clippy::unnecessary_wraps)]
|
#[allow(clippy::unnecessary_wraps)]
|
||||||
|
|
Loading…
Reference in New Issue