From 9d3afba04547fd20aa5cb75bed1c6f23424c837b Mon Sep 17 00:00:00 2001 From: "Jeff Washington (jwash)" <75863576+jeffwashington@users.noreply.github.com> Date: Tue, 31 Aug 2021 09:04:56 -0500 Subject: [PATCH] Debug shrink stats (#19505) * add some shrink metrics * renames --- runtime/src/accounts_db.rs | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/runtime/src/accounts_db.rs b/runtime/src/accounts_db.rs index d6b6ae1b39..1082b7719d 100644 --- a/runtime/src/accounts_db.rs +++ b/runtime/src/accounts_db.rs @@ -1220,6 +1220,9 @@ struct ShrinkStats { bytes_removed: AtomicU64, bytes_written: AtomicU64, skipped_shrink: AtomicU64, + dead_accounts: AtomicU64, + alive_accounts: AtomicU64, + cancelled_shrink: AtomicU64, } impl ShrinkStats { @@ -1308,6 +1311,21 @@ impl ShrinkStats { self.skipped_shrink.swap(0, Ordering::Relaxed) as i64, i64 ), + ( + "alive_accounts", + self.alive_accounts.swap(0, Ordering::Relaxed) as i64, + i64 + ), + ( + "dead_accounts", + self.dead_accounts.swap(0, Ordering::Relaxed) as i64, + i64 + ), + ( + "cancelled_shrink", + self.cancelled_shrink.swap(0, Ordering::Relaxed) as i64, + i64 + ), ); } } @@ -2271,10 +2289,16 @@ impl AccountsDb { // not exist in the re-written slot. Unref it to keep the index consistent with // rewriting the storage entries. unrefed_pubkeys.push(pubkey); - locked_entry.unref() + locked_entry.unref(); + self.shrink_stats + .dead_accounts + .fetch_add(1, Ordering::Relaxed); } else { alive_accounts.push((pubkey, stored_account)); alive_total += stored_account.account_size; + self.shrink_stats + .alive_accounts + .fetch_add(1, Ordering::Relaxed); } } } @@ -2287,6 +2311,9 @@ impl AccountsDb { self.shrink_stats .skipped_shrink .fetch_add(1, Ordering::Relaxed); + self.shrink_stats + .cancelled_shrink + .fetch_add(1, Ordering::Relaxed); for pubkey in unrefed_pubkeys { if let Some(locked_entry) = self.accounts_index.get_account_read_entry(pubkey) { locked_entry.addref();