Skip to content

Commit

Permalink
add stats on clean (solana-labs#2703)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffwashington authored Aug 23, 2024
1 parent 09f5f5b commit fc84a52
Showing 1 changed file with 27 additions and 14 deletions.
41 changes: 27 additions & 14 deletions accounts-db/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -8043,20 +8051,25 @@ impl AccountsDb {
dead_slots.insert(*slot);
}
else {
let mut offsets = offsets.iter().cloned().collect::<Vec<_>>();
// 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::<Vec<_>>();
// 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);
}
}
});
Expand Down

0 comments on commit fc84a52

Please sign in to comment.