diff --git a/accounts-db/src/accounts_db.rs b/accounts-db/src/accounts_db.rs index 9095a29b19cc50..641c7d63f9f013 100644 --- a/accounts-db/src/accounts_db.rs +++ b/accounts-db/src/accounts_db.rs @@ -1959,6 +1959,7 @@ struct CleanAccountsStats { remove_dead_accounts_shrink_us: AtomicU64, clean_stored_dead_slots_us: AtomicU64, uncleaned_roots_slot_list_1: AtomicU64, + get_account_sizes_us: AtomicU64, } impl CleanAccountsStats { @@ -3593,6 +3594,13 @@ impl AccountsDb { .swap(0, Ordering::Relaxed), i64 ), + ( + "get_account_sizes_us", + self.clean_accounts_stats + .get_account_sizes_us + .swap(0, Ordering::Relaxed), + i64 + ), ( "clean_old_root_us", self.clean_accounts_stats @@ -8043,20 +8051,25 @@ impl AccountsDb { dead_slots.insert(*slot); } else { - let mut offsets = offsets.iter().cloned().collect::>(); - // sort so offsets are in order. This improves efficiency of loading the accounts. - offsets.sort_unstable(); - let dead_bytes = store.accounts.get_account_sizes(&offsets).iter().sum(); - store.remove_accounts(dead_bytes, reset_accounts, offsets.len()); - if Self::is_shrinking_productive(*slot, &store) - && self.is_candidate_for_shrink(&store) - { - // Checking that this single storage entry is ready for shrinking, - // should be a sufficient indication that the slot is ready to be shrunk - // because slots should only have one storage entry, namely the one that was - // created by `flush_slot_cache()`. - new_shrink_candidates.insert(*slot); - } + let (_, us) = measure_us!({ + let mut offsets = offsets.iter().cloned().collect::>(); + // sort so offsets are in order. This improves efficiency of loading the accounts. + offsets.sort_unstable(); + let dead_bytes = store.accounts.get_account_sizes(&offsets).iter().sum(); + store.remove_accounts(dead_bytes, reset_accounts, offsets.len()); + if Self::is_shrinking_productive(*slot, &store) + && self.is_candidate_for_shrink(&store) + { + // Checking that this single storage entry is ready for shrinking, + // should be a sufficient indication that the slot is ready to be shrunk + // because slots should only have one storage entry, namely the one that was + // created by `flush_slot_cache()`. + new_shrink_candidates.insert(*slot); + } + }); + self.clean_accounts_stats + .get_account_sizes_us + .fetch_add(us, Ordering::Relaxed); } } });