fix some ancient stats (#33791)

This commit is contained in:
Jeff Washington (jwash) 2023-10-23 07:23:47 -07:00 committed by GitHub
parent 34103e0913
commit a41b24f185
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 11 deletions

View File

@ -2041,7 +2041,7 @@ pub(crate) struct ShrinkAncientStats {
pub(crate) random_shrink: AtomicU64,
pub(crate) slots_considered: AtomicU64,
pub(crate) ancient_scanned: AtomicU64,
pub(crate) second_pass_one_ref: AtomicU64,
pub(crate) bytes_ancient_created: AtomicU64,
}
#[derive(Debug, Default)]
@ -2072,7 +2072,7 @@ impl ShrinkStatsSub {
#[derive(Debug, Default)]
pub struct ShrinkStats {
last_report: AtomicInterval,
num_slots_shrunk: AtomicUsize,
pub(crate) num_slots_shrunk: AtomicUsize,
storage_read_elapsed: AtomicU64,
index_read_elapsed: AtomicU64,
create_and_insert_store_elapsed: AtomicU64,
@ -2346,8 +2346,8 @@ impl ShrinkAncientStats {
i64
),
(
"second_pass_one_ref",
self.second_pass_one_ref.swap(0, Ordering::Relaxed) as i64,
"bytes_ancient_created",
self.bytes_ancient_created.swap(0, Ordering::Relaxed) as i64,
i64
),
);
@ -4204,14 +4204,20 @@ impl AccountsDb {
);
}
Self::update_shrink_stats(&self.shrink_stats, stats_sub);
Self::update_shrink_stats(&self.shrink_stats, stats_sub, true);
self.shrink_stats.report();
}
pub(crate) fn update_shrink_stats(shrink_stats: &ShrinkStats, stats_sub: ShrinkStatsSub) {
shrink_stats
.num_slots_shrunk
.fetch_add(1, Ordering::Relaxed);
pub(crate) fn update_shrink_stats(
shrink_stats: &ShrinkStats,
stats_sub: ShrinkStatsSub,
increment_count: bool,
) {
if increment_count {
shrink_stats
.num_slots_shrunk
.fetch_add(1, Ordering::Relaxed);
}
shrink_stats.create_and_insert_store_elapsed.fetch_add(
stats_sub.create_and_insert_store_elapsed_us,
Ordering::Relaxed,
@ -4752,7 +4758,7 @@ impl AccountsDb {
// we should not try to shrink any of the stores from this slot anymore. All shrinking for this slot is now handled by ancient append vec code.
self.shrink_candidate_slots.lock().unwrap().remove(&slot);
Self::update_shrink_stats(&self.shrink_ancient_stats.shrink_stats, stats_sub);
Self::update_shrink_stats(&self.shrink_ancient_stats.shrink_stats, stats_sub, true);
}
/// each slot in 'dropped_roots' has been combined into an ancient append vec.

View File

@ -266,7 +266,7 @@ impl AccountsDb {
&mut stats_sub
));
Self::update_shrink_stats(&self.shrink_ancient_stats.shrink_stats, stats_sub);
Self::update_shrink_stats(&self.shrink_ancient_stats.shrink_stats, stats_sub, false);
self.shrink_ancient_stats
.total_us
.fetch_add(total_us, Ordering::Relaxed);
@ -516,6 +516,9 @@ impl AccountsDb {
self.thread_pool_clean.install(|| {
packer.par_iter().for_each(|(target_slot, pack)| {
let mut write_ancient_accounts_local = WriteAncientAccounts::default();
self.shrink_ancient_stats
.bytes_ancient_created
.fetch_add(pack.bytes, Ordering::Relaxed);
self.write_one_packed_storage(
pack,
**target_slot,
@ -694,6 +697,13 @@ impl AccountsDb {
INCLUDE_SLOT_IN_HASH_IRRELEVANT_APPEND_VEC_OPERATION,
);
self.shrink_ancient_stats
.bytes_ancient_created
.fetch_add(packed.bytes, Ordering::Relaxed);
self.shrink_ancient_stats
.shrink_stats
.num_slots_shrunk
.fetch_add(1, Ordering::Relaxed);
self.write_ancient_accounts(*bytes_total, accounts_to_write, write_ancient_accounts)
}