remove unused bank creation/freezing progress (#32699)

This commit is contained in:
Jeff Washington (jwash) 2023-08-03 10:12:44 -07:00 committed by GitHub
parent 33c33f5f79
commit f5c8bb789a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 0 additions and 153 deletions

View File

@ -55,7 +55,6 @@ use {
aligned_stored_size, AppendVec, MatchAccountOwnerError, APPEND_VEC_MMAPPED_FILES_OPEN,
STORE_META_OVERHEAD,
},
bank_creation_freezing_progress::BankCreationFreezingProgress,
cache_hash_data::{CacheHashData, CacheHashDataFile},
contains::Contains,
epoch_accounts_hash::EpochAccountsHashManager,
@ -1505,8 +1504,6 @@ pub struct AccountsDb {
/// Some time later (to allow for slow calculation time), the bank hash at a slot calculated using 'M' includes the full accounts hash.
/// Thus, the state of all accounts on a validator is known to be correct at least once per epoch.
pub epoch_accounts_hash_manager: EpochAccountsHashManager,
pub(crate) bank_progress: BankCreationFreezingProgress,
}
#[derive(Debug, Default)]
@ -2383,7 +2380,6 @@ impl AccountsDb {
const ACCOUNTS_STACK_SIZE: usize = 8 * 1024 * 1024;
AccountsDb {
bank_progress: BankCreationFreezingProgress::default(),
create_ancient_storage: CreateAncientStorage::Pack,
verify_accounts_hash_in_bg: VerifyAccountsHashInBackground::default(),
filler_accounts_per_slot: AtomicU64::default(),
@ -4042,7 +4038,6 @@ impl AccountsDb {
Self::update_shrink_stats(&self.shrink_stats, stats_sub);
self.shrink_stats.report();
self.bank_progress.report();
}
pub(crate) fn update_shrink_stats(shrink_stats: &ShrinkStats, stats_sub: ShrinkStatsSub) {

View File

@ -491,7 +491,6 @@ impl PartialEq for Bank {
return true;
}
let Self {
bank_freeze_or_destruction_incremented: _,
rc: _,
status_cache: _,
blockhash_queue,
@ -820,9 +819,6 @@ pub struct Bank {
pub check_program_modification_slot: bool,
/// true when the bank's freezing or destruction has completed
bank_freeze_or_destruction_incremented: AtomicBool,
epoch_reward_status: EpochRewardStatus,
}
@ -1029,7 +1025,6 @@ impl Bank {
fn default_with_accounts(accounts: Accounts) -> Self {
let mut bank = Self {
bank_freeze_or_destruction_incremented: AtomicBool::default(),
incremental_snapshot_persistence: None,
rc: BankRc::new(accounts, Slot::default()),
status_cache: Arc::<RwLock<BankStatusCache>>::default(),
@ -1092,7 +1087,6 @@ impl Bank {
epoch_reward_status: EpochRewardStatus::default(),
};
bank.bank_created();
let accounts_data_size_initial = bank.get_total_accounts_stats().unwrap().data_len as u64;
bank.accounts_data_size_initial = accounts_data_size_initial;
@ -1359,9 +1353,7 @@ impl Bank {
let (feature_set, feature_set_time_us) = measure_us!(parent.feature_set.clone());
let accounts_data_size_initial = parent.load_accounts_data_size();
parent.bank_created();
let mut new = Self {
bank_freeze_or_destruction_incremented: AtomicBool::default(),
incremental_snapshot_persistence: None,
rc,
status_cache,
@ -1728,27 +1720,6 @@ impl Bank {
self.vote_only_bank
}
fn bank_created(&self) {
self.rc
.accounts
.accounts_db
.bank_progress
.increment_bank_creation_count();
}
fn bank_frozen_or_destroyed(&self) {
if !self
.bank_freeze_or_destruction_incremented
.swap(true, AcqRel)
{
self.rc
.accounts
.accounts_db
.bank_progress
.increment_bank_frozen_or_destroyed();
}
}
/// Like `new_from_parent` but additionally:
/// * Doesn't assume that the parent is anywhere near `slot`, parent could be millions of slots
/// in the past
@ -1832,7 +1803,6 @@ impl Bank {
let feature_set = new();
let mut bank = Self {
incremental_snapshot_persistence: fields.incremental_snapshot_persistence,
bank_freeze_or_destruction_incremented: AtomicBool::default(),
rc: bank_rc,
status_cache: new(),
blockhash_queue: RwLock::new(fields.blockhash_queue),
@ -1893,8 +1863,6 @@ impl Bank {
check_program_modification_slot: false,
epoch_reward_status: EpochRewardStatus::default(),
};
bank.bank_created();
bank.finish_init(
genesis_config,
additional_builtins,
@ -3774,7 +3742,6 @@ impl Bank {
self.freeze_started.store(true, Relaxed);
*hash = self.hash_internal_state();
self.rc.accounts.accounts_db.mark_slot_frozen(self.slot());
self.bank_frozen_or_destroyed();
}
}
@ -8333,7 +8300,6 @@ impl TotalAccountsStats {
impl Drop for Bank {
fn drop(&mut self) {
self.bank_frozen_or_destroyed();
if let Some(drop_callback) = self.drop_callback.read().unwrap().0.as_ref() {
drop_callback.callback(self);
} else {

View File

@ -1,113 +0,0 @@
//! Keep track of how many banks have been created and how many have been frozen or dropped.
//! This is useful to track foreground progress to understand expected access to accounts db.
use {
crate::waitable_condvar::WaitableCondvar,
solana_sdk::timing::AtomicInterval,
std::sync::{
atomic::{AtomicU32, Ordering},
Arc,
},
};
#[derive(Debug, Default)]
/// Keeps track of when all banks that were started as of a known point in time have been frozen or otherwise destroyed.
/// When 'bank_freeze_or_destruction_count' exceeds a prior value of 'bank_creation_count',
/// this means that we can know all banks that began loading accounts have completed as of the prior value of 'bank_creation_count'.
pub(crate) struct BankCreationFreezingProgress {
/// Incremented each time a bank is created.
/// Starting now, this bank could be finding accounts in the index and loading them from accounts db.
bank_creation_count: AtomicU32,
/// Incremented each time a bank is frozen or destroyed.
/// At this point, this bank has completed all account loading.
bank_freeze_or_destruction_count: AtomicU32,
/// enable waiting for bank_freeze_or_destruction_count to increment
bank_frozen_or_destroyed: Arc<WaitableCondvar>,
last_report: AtomicInterval,
}
impl BankCreationFreezingProgress {
pub(crate) fn increment_bank_frozen_or_destroyed(&self) {
self.bank_freeze_or_destruction_count
.fetch_add(1, Ordering::Release);
self.bank_frozen_or_destroyed.notify_all();
}
pub(crate) fn get_bank_frozen_or_destroyed_count(&self) -> u32 {
self.bank_freeze_or_destruction_count
.load(Ordering::Acquire)
}
pub(crate) fn increment_bank_creation_count(&self) {
self.bank_creation_count.fetch_add(1, Ordering::Release);
}
pub(crate) fn get_bank_creation_count(&self) -> u32 {
self.bank_creation_count.load(Ordering::Acquire)
}
pub(crate) fn report(&self) {
if self.last_report.should_update(60_000) {
datapoint_info!(
"bank_progress",
(
"difference",
self.get_bank_creation_count()
.wrapping_sub(self.get_bank_frozen_or_destroyed_count()),
i64
)
);
}
}
}
#[cfg(test)]
pub mod tests {
use {super::*, solana_sdk::timing::timestamp, std::thread::Builder};
#[test]
fn test_count() {
solana_logger::setup();
let progress = BankCreationFreezingProgress::default();
assert_eq!(progress.get_bank_creation_count(), 0);
assert_eq!(progress.get_bank_frozen_or_destroyed_count(), 0);
progress.increment_bank_creation_count();
assert_eq!(progress.get_bank_creation_count(), 1);
assert_eq!(progress.get_bank_frozen_or_destroyed_count(), 0);
progress.increment_bank_frozen_or_destroyed();
assert_eq!(progress.get_bank_creation_count(), 1);
assert_eq!(progress.get_bank_frozen_or_destroyed_count(), 1);
}
#[test]
fn test_wait() {
solana_logger::setup();
let progress = BankCreationFreezingProgress::default();
let waiter = progress.bank_frozen_or_destroyed.clone();
let duration = std::time::Duration::default();
assert!(waiter.wait_timeout(duration));
let tester = Arc::new(AtomicU32::default());
let tester2 = tester.clone();
let thread = Builder::new()
.name("test_wait".to_string())
.spawn(move || {
assert!(!waiter.wait_timeout(std::time::Duration::from_secs(5)));
tester2.store(1, Ordering::Release);
})
.unwrap();
let start = timestamp();
let mut i = 0;
while tester.load(Ordering::Acquire) == 0 {
// keep incrementing until the waiter thread has picked up the notification that we incremented
progress.increment_bank_frozen_or_destroyed();
i += 1;
assert_eq!(progress.get_bank_frozen_or_destroyed_count(), i);
let now = timestamp();
let elapsed = now.wrapping_sub(start);
assert!(elapsed < 5_000, "elapsed: {elapsed}");
}
thread.join().expect("failed");
}
}

View File

@ -24,7 +24,6 @@ mod ancient_append_vecs;
pub mod append_vec;
pub mod bank;
pub mod bank_client;
mod bank_creation_freezing_progress;
pub mod bank_forks;
pub mod bank_utils;
pub mod blockhash_queue;