Skip to content

Commit

Permalink
add ancient pack metrics (solana-labs#2206)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffwashington authored Jul 19, 2024
1 parent 5b6485a commit 54935e7
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
12 changes: 12 additions & 0 deletions accounts-db/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1957,6 +1957,8 @@ pub(crate) struct ShrinkAncientStats {
pub(crate) many_ref_slots_skipped: AtomicU64,
pub(crate) slots_cannot_move_count: AtomicU64,
pub(crate) many_refs_old_alive: AtomicU64,
pub(crate) slots_eligible_to_shrink: AtomicU64,
pub(crate) total_dead_bytes: AtomicU64,
}

#[derive(Debug, Default)]
Expand Down Expand Up @@ -2239,6 +2241,16 @@ impl ShrinkAncientStats {
self.random_shrink.swap(0, Ordering::Relaxed) as i64,
i64
),
(
"slots_eligible_to_shrink",
self.slots_eligible_to_shrink.swap(0, Ordering::Relaxed),
i64
),
(
"total_dead_bytes",
self.total_dead_bytes.swap(0, Ordering::Relaxed),
i64
),
(
"slots_considered",
self.slots_considered.swap(0, Ordering::Relaxed) as i64,
Expand Down
14 changes: 14 additions & 0 deletions accounts-db/src/ancient_append_vecs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,20 @@ impl AccountsDb {
}
}
}
let mut total_dead_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))
.count()
.saturating_sub(randoms as usize);
self.shrink_ancient_stats
.slots_eligible_to_shrink
.fetch_add(should_shrink_count as u64, Ordering::Relaxed);
self.shrink_ancient_stats
.total_dead_bytes
.fetch_add(total_dead_bytes, Ordering::Relaxed);
if randoms > 0 {
self.shrink_ancient_stats
.random_shrink
Expand Down

0 comments on commit 54935e7

Please sign in to comment.