Skip to content

Commit

Permalink
add ancient.total_alive_bytes metric
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffwashington committed Sep 3, 2024
1 parent a9ac3f5 commit 81f85b9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions accounts-db/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
9 changes: 8 additions & 1 deletion accounts-db/src/ancient_append_vecs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 81f85b9

Please sign in to comment.