Skip to content

Commit

Permalink
add metric for ancient can't move slots (#33713)
Browse files Browse the repository at this point in the history
* add metric for ancient can't move slots

* rename

* fix erors in replacing text

* rename
  • Loading branch information
jeffwashington authored Oct 17, 2023
1 parent b241cef commit 5de9163
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
14 changes: 13 additions & 1 deletion accounts-db/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2014,10 +2014,10 @@ pub(crate) struct ShrinkStatsSub {
pub(crate) store_accounts_timing: StoreAccountsTiming,
pub(crate) rewrite_elapsed_us: u64,
pub(crate) create_and_insert_store_elapsed_us: u64,
pub(crate) unpackable_slots_count: usize,
}

impl ShrinkStatsSub {
#[allow(dead_code)]
pub(crate) fn accumulate(&mut self, other: &Self) {
self.store_accounts_timing
.accumulate(&other.store_accounts_timing);
Expand All @@ -2026,6 +2026,7 @@ impl ShrinkStatsSub {
self.create_and_insert_store_elapsed_us,
other.create_and_insert_store_elapsed_us
);
saturating_add_assign!(self.unpackable_slots_count, other.unpackable_slots_count);
}
}

Expand All @@ -2041,6 +2042,7 @@ pub struct ShrinkStats {
handle_reclaims_elapsed: AtomicU64,
remove_old_stores_shrink_us: AtomicU64,
rewrite_elapsed: AtomicU64,
unpackable_slots_count: AtomicU64,
drop_storage_entries_elapsed: AtomicU64,
recycle_stores_write_elapsed: AtomicU64,
accounts_removed: AtomicUsize,
Expand Down Expand Up @@ -2219,6 +2221,13 @@ impl ShrinkAncientStats {
self.shrink_stats.rewrite_elapsed.swap(0, Ordering::Relaxed) as i64,
i64
),
(
"unpackable_slots_count",
self.shrink_stats
.unpackable_slots_count
.swap(0, Ordering::Relaxed) as i64,
i64
),
(
"drop_storage_entries_elapsed",
self.shrink_stats
Expand Down Expand Up @@ -4177,6 +4186,9 @@ impl AccountsDb {
shrink_stats
.rewrite_elapsed
.fetch_add(stats_sub.rewrite_elapsed_us, Ordering::Relaxed);
shrink_stats
.unpackable_slots_count
.fetch_add(stats_sub.unpackable_slots_count as u64, Ordering::Relaxed);
}

/// get stores for 'slot'
Expand Down
7 changes: 7 additions & 0 deletions accounts-db/src/ancient_append_vecs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ impl AccountsDb {
);

let accounts_to_combine = self.calc_accounts_to_combine(&accounts_per_storage);
metrics.unpackable_slots_count += accounts_to_combine.unpackable_slots_count;

// pack the accounts with 1 ref
let pack = PackedAncientStorage::pack(
Expand Down Expand Up @@ -385,6 +386,7 @@ impl AccountsDb {
store_accounts_timing,
rewrite_elapsed_us,
create_and_insert_store_elapsed_us,
unpackable_slots_count: 0,
});
write_ancient_accounts
.shrinks_in_progress
Expand Down Expand Up @@ -584,13 +586,15 @@ impl AccountsDb {
target_slots_sorted.push(info.slot);
}
}
let unpackable_slots_count = remove.len();
remove.into_iter().rev().for_each(|i| {
accounts_to_combine.remove(i);
});
AccountsToCombine {
accounts_to_combine,
accounts_keep_slots,
target_slots_sorted,
unpackable_slots_count,
}
}

Expand Down Expand Up @@ -718,6 +722,8 @@ struct AccountsToCombine<'a> {
/// Some of these slots will have ancient append vecs created at them to contain everything in 'accounts_to_combine'
/// The rest will become dead slots with no accounts in them.
target_slots_sorted: Vec<Slot>,
/// when scanning, this many slots contained accounts that could not be packed because accounts with ref_count > 1 existed.
unpackable_slots_count: usize,
}

#[derive(Default)]
Expand Down Expand Up @@ -3135,6 +3141,7 @@ pub mod tests {
accounts_keep_slots: HashMap::default(),
accounts_to_combine: vec![shrink_collect],
target_slots_sorted: Vec::default(),
unpackable_slots_count: 0,
};
db.addref_accounts_failed_to_shrink_ancient(accounts_to_combine);
db.accounts_index.scan(
Expand Down

0 comments on commit 5de9163

Please sign in to comment.