Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

add metric for ancient can't move slots #33713

Merged
merged 4 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) number_unpackable_slots: 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.number_unpackable_slots, other.number_unpackable_slots);
}
}

Expand All @@ -2041,6 +2042,7 @@ pub struct ShrinkStats {
handle_reclaims_elapsed: AtomicU64,
remove_old_stores_shrink_us: AtomicU64,
rewrite_elapsed: AtomicU64,
number_unpackable_slots: 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
),
(
"number_unpackable_slots",
self.shrink_stats
.number_unpackable_slots
.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
.number_unpackable_slots
.fetch_add(stats_sub.number_unpackable_slots 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.number_unpackable_slots += accounts_to_combine.number_unpackable_slots;

// 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,
number_unpackable_slots: 0,
});
write_ancient_accounts
.shrinks_in_progress
Expand Down Expand Up @@ -584,13 +586,15 @@ impl AccountsDb {
target_slots_sorted.push(info.slot);
}
}
let number_unpackable_slots = remove.len();
remove.into_iter().rev().for_each(|i| {
accounts_to_combine.remove(i);
});
AccountsToCombine {
accounts_to_combine,
accounts_keep_slots,
target_slots_sorted,
number_unpackable_slots,
}
}

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.
number_unpackable_slots: 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(),
number_unpackable_slots: 0,
};
db.addref_accounts_failed_to_shrink_ancient(accounts_to_combine);
db.accounts_index.scan(
Expand Down