add metrics around purge_exact (#32752)

This commit is contained in:
Jeff Washington (jwash) 2023-08-08 07:15:21 -07:00 committed by GitHub
parent e2843d3fd0
commit 21b8b70bee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 5 deletions

View File

@ -1528,6 +1528,9 @@ pub struct AccountsStats {
store_find_existing: AtomicU64, store_find_existing: AtomicU64,
dropped_stores: AtomicU64, dropped_stores: AtomicU64,
store_uncleaned_update: AtomicU64, store_uncleaned_update: AtomicU64,
handle_dead_keys_us: AtomicU64,
purge_exact_us: AtomicU64,
purge_exact_count: AtomicU64,
} }
#[derive(Debug, Default)] #[derive(Debug, Default)]
@ -2841,18 +2844,30 @@ impl AccountsDb {
let mut reclaims = Vec::new(); let mut reclaims = Vec::new();
let mut dead_keys = Vec::new(); let mut dead_keys = Vec::new();
for (pubkey, slots_set) in pubkey_to_slot_set { let mut purge_exact_count = 0;
let (_, purge_exact_us) = measure_us!(for (pubkey, slots_set) in pubkey_to_slot_set {
purge_exact_count += 1;
let is_empty = self let is_empty = self
.accounts_index .accounts_index
.purge_exact(pubkey, slots_set, &mut reclaims); .purge_exact(pubkey, slots_set, &mut reclaims);
if is_empty { if is_empty {
dead_keys.push(pubkey); dead_keys.push(pubkey);
} }
} });
let pubkeys_removed_from_accounts_index = self let (pubkeys_removed_from_accounts_index, handle_dead_keys_us) = measure_us!(self
.accounts_index .accounts_index
.handle_dead_keys(&dead_keys, &self.account_indexes); .handle_dead_keys(&dead_keys, &self.account_indexes));
self.stats
.purge_exact_count
.fetch_add(purge_exact_count, Ordering::Relaxed);
self.stats
.handle_dead_keys_us
.fetch_add(handle_dead_keys_us, Ordering::Relaxed);
self.stats
.purge_exact_us
.fetch_add(purge_exact_us, Ordering::Relaxed);
(reclaims, pubkeys_removed_from_accounts_index) (reclaims, pubkeys_removed_from_accounts_index)
} }
@ -8463,6 +8478,21 @@ impl AccountsDb {
self.stats.calc_stored_meta.swap(0, Ordering::Relaxed), self.stats.calc_stored_meta.swap(0, Ordering::Relaxed),
i64 i64
), ),
(
"handle_dead_keys_us",
self.stats.handle_dead_keys_us.swap(0, Ordering::Relaxed),
i64
),
(
"purge_exact_us",
self.stats.purge_exact_us.swap(0, Ordering::Relaxed),
i64
),
(
"purge_exact_count",
self.stats.purge_exact_count.swap(0, Ordering::Relaxed),
i64
),
); );
let recycle_stores = self.recycle_stores.read().unwrap(); let recycle_stores = self.recycle_stores.read().unwrap();

View File

@ -1260,7 +1260,10 @@ impl<T: IndexValue, U: DiskIndexValue + From<T> + Into<T>> AccountsIndex<T, U> {
.collect() .collect()
} }
pub fn purge_exact<'a, C>( /// returns true if, after this fn call:
/// accounts index entry for `pubkey` has an empty slot list
/// or `pubkey` does not exist in accounts index
pub(crate) fn purge_exact<'a, C>(
&'a self, &'a self,
pubkey: &Pubkey, pubkey: &Pubkey,
slots_to_purge: &'a C, slots_to_purge: &'a C,