Skip to content

Commit

Permalink
metric: add unref_zero_count stat (#2791)
Browse files Browse the repository at this point in the history
* add unref_zero_count stat

* put unref_zero_count stat on accounts_index

---------

Co-authored-by: HaoranYi <[email protected]>
  • Loading branch information
HaoranYi and HaoranYi committed Aug 30, 2024
1 parent f79cea1 commit 8a219de
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions accounts-db/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3717,6 +3717,13 @@ impl AccountsDb {
.swap(0, Ordering::Relaxed),
i64
),
(
"unref_zero_count",
self.accounts_index
.unref_zero_count
.swap(0, Ordering::Relaxed),
i64
),
(
"ancient_account_cleans",
ancient_account_cleans.load(Ordering::Relaxed),
Expand Down
4 changes: 4 additions & 0 deletions accounts-db/src/accounts_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,8 @@ pub struct AccountsIndex<T: IndexValue, U: DiskIndexValue + From<T> + Into<T>> {
pub active_scans: AtomicUsize,
/// # of slots between latest max and latest scan
pub max_distance_to_min_scan_slot: AtomicU64,
// # of unref when the account's ref_count is zero
pub unref_zero_count: AtomicU64,

/// populated at generate_index time - accounts that could possibly be rent paying
pub rent_paying_accounts_by_partition: OnceLock<RentPayingAccountsByPartition>,
Expand Down Expand Up @@ -724,6 +726,7 @@ impl<T: IndexValue, U: DiskIndexValue + From<T> + Into<T>> AccountsIndex<T, U> {
roots_removed: AtomicUsize::default(),
active_scans: AtomicUsize::default(),
max_distance_to_min_scan_slot: AtomicU64::default(),
unref_zero_count: AtomicU64::default(),
rent_paying_accounts_by_partition: OnceLock::default(),
}
}
Expand Down Expand Up @@ -1452,6 +1455,7 @@ impl<T: IndexValue, U: DiskIndexValue + From<T> + Into<T>> AccountsIndex<T, U> {
AccountsIndexScanResult::Unref => {
if locked_entry.unref() {
info!("scan: refcount of item already at 0: {pubkey}");
self.unref_zero_count.fetch_add(1, Ordering::Relaxed);
}
true
}
Expand Down

0 comments on commit 8a219de

Please sign in to comment.