diff --git a/accounts-db/src/accounts_db.rs b/accounts-db/src/accounts_db.rs index b162ee1abe9330..49de51d459edb9 100644 --- a/accounts-db/src/accounts_db.rs +++ b/accounts-db/src/accounts_db.rs @@ -1997,6 +1997,7 @@ pub(crate) struct ShrinkAncientStats { pub(crate) slots_eligible_to_shrink: AtomicU64, pub(crate) total_dead_bytes: AtomicU64, pub(crate) total_alive_bytes: AtomicU64, + pub(crate) ideal_storage_size: AtomicU64, } #[derive(Debug, Default)] @@ -2043,9 +2044,12 @@ pub struct ShrinkStats { index_scan_returned_none: AtomicU64, index_scan_returned_some: AtomicU64, accounts_loaded: AtomicU64, + initial_candidates_count: AtomicU64, purged_zero_lamports: AtomicU64, accounts_not_found_in_index: AtomicU64, num_ancient_slots_shrunk: AtomicU64, + ancient_slots_added_to_shrink: AtomicU64, + ancient_bytes_added_to_shrink: AtomicU64, } impl ShrinkStats { @@ -2053,6 +2057,16 @@ impl ShrinkStats { if self.last_report.should_update(1000) { datapoint_info!( "shrink_stats", + ( + "ancient_slots_added_to_shrink", + self.ancient_slots_added_to_shrink.swap(0, Ordering::Relaxed) as i64, + i64 + ), + ( + "ancient_bytes_added_to_shrink", + self.ancient_bytes_added_to_shrink.swap(0, Ordering::Relaxed) as i64, + i64 + ), ( "num_slots_shrunk", self.num_slots_shrunk.swap(0, Ordering::Relaxed) as i64, @@ -2169,6 +2183,11 @@ impl ShrinkStats { self.accounts_not_found_in_index.swap(0, Ordering::Relaxed), i64 ), + ( + "initial_candidates_count", + self.initial_candidates_count.swap(0, Ordering::Relaxed), + i64 + ), ); } } @@ -2328,6 +2347,11 @@ impl ShrinkAncientStats { self.slots_eligible_to_shrink.swap(0, Ordering::Relaxed), i64 ), + ( + "ideal_storage_size", + self.ideal_storage_size.swap(0, Ordering::Relaxed), + i64 + ), ( "total_dead_bytes", self.total_dead_bytes.swap(0, Ordering::Relaxed), @@ -5074,6 +5098,10 @@ impl AccountsDb { let shrink_candidates_slots = std::mem::take(&mut *self.shrink_candidate_slots.lock().unwrap()); + self.shrink_stats + .initial_candidates_count + .store(shrink_candidates_slots.len() as u64, Ordering::Relaxed); + let (mut shrink_slots, shrink_slots_next_batch) = { if let AccountShrinkThreshold::TotalSpace { shrink_ratio } = self.shrink_ratio { let (shrink_slots, shrink_slots_next_batch) = diff --git a/accounts-db/src/ancient_append_vecs.rs b/accounts-db/src/ancient_append_vecs.rs index 6c8d3396d57252..757777424407b8 100644 --- a/accounts-db/src/ancient_append_vecs.rs +++ b/accounts-db/src/ancient_append_vecs.rs @@ -609,6 +609,9 @@ impl AccountsDb { (infos.total_alive_bytes.0 / tuning.max_ancient_slots.max(1) as u64 * 2).max(5_000_000), ) .unwrap(); + self.shrink_ancient_stats + .ideal_storage_size + .store(tuning.ideal_storage_size.into(), Ordering::Relaxed); self.shrink_ancient_stats .slots_eligible_to_shrink .fetch_add(should_shrink_count as u64, Ordering::Relaxed);