diff --git a/accounts-db/src/accounts_db.rs b/accounts-db/src/accounts_db.rs index aa98b65e3aba72..7e51234ea93a8c 100644 --- a/accounts-db/src/accounts_db.rs +++ b/accounts-db/src/accounts_db.rs @@ -1990,6 +1990,7 @@ pub(crate) struct ShrinkAncientStats { pub(crate) many_refs_old_alive: AtomicU64, pub(crate) slots_eligible_to_shrink: AtomicU64, pub(crate) total_dead_bytes: AtomicU64, + pub(crate) total_alive_bytes: AtomicU64, } #[derive(Debug, Default)] @@ -2320,6 +2321,11 @@ impl ShrinkAncientStats { self.total_dead_bytes.swap(0, Ordering::Relaxed), i64 ), + ( + "total_alive_bytes", + self.total_alive_bytes.swap(0, Ordering::Relaxed), + i64 + ), ( "slots_considered", self.slots_considered.swap(0, Ordering::Relaxed) as i64, diff --git a/accounts-db/src/ancient_append_vecs.rs b/accounts-db/src/ancient_append_vecs.rs index 24ec415b792a3f..95d45bfc93d573 100644 --- a/accounts-db/src/ancient_append_vecs.rs +++ b/accounts-db/src/ancient_append_vecs.rs @@ -584,11 +584,15 @@ impl AccountsDb { } } let mut total_dead_bytes = 0; + let mut total_alive_bytes = 0; let should_shrink_count = infos .all_infos .iter() .filter(|info| info.should_shrink) - .map(|info| total_dead_bytes += info.capacity.saturating_sub(info.alive_bytes)) + .map(|info| { + total_dead_bytes += info.capacity.saturating_sub(info.alive_bytes); + total_alive_bytes += info.alive_bytes; + }) .count() .saturating_sub(randoms as usize); self.shrink_ancient_stats @@ -597,6 +601,9 @@ impl AccountsDb { self.shrink_ancient_stats .total_dead_bytes .fetch_add(total_dead_bytes, Ordering::Relaxed); + self.shrink_ancient_stats + .total_alive_bytes + .fetch_add(total_alive_bytes, Ordering::Relaxed); if randoms > 0 { self.shrink_ancient_stats .random_shrink