avoid zeroing out root stats with empty data (#25111)

This commit is contained in:
Jeff Washington (jwash) 2022-05-10 13:56:30 -05:00 committed by GitHub
parent b91cc87680
commit e9a9604ca7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 26 deletions

View File

@ -1258,22 +1258,22 @@ struct LatestAccountsIndexRootsStats {
impl LatestAccountsIndexRootsStats {
fn update(&self, accounts_index_roots_stats: &AccountsIndexRootsStats) {
self.roots_len
.store(accounts_index_roots_stats.roots_len, Ordering::Relaxed);
self.uncleaned_roots_len.store(
accounts_index_roots_stats.uncleaned_roots_len,
Ordering::Relaxed,
);
self.previous_uncleaned_roots_len.store(
accounts_index_roots_stats.previous_uncleaned_roots_len,
Ordering::Relaxed,
);
self.historical_roots_len.store(
accounts_index_roots_stats.historical_roots_len,
Ordering::Relaxed,
);
self.roots_range
.store(accounts_index_roots_stats.roots_range, Ordering::Relaxed);
if let Some(value) = accounts_index_roots_stats.roots_len {
self.roots_len.store(value, Ordering::Relaxed);
}
if let Some(value) = accounts_index_roots_stats.uncleaned_roots_len {
self.uncleaned_roots_len.store(value, Ordering::Relaxed);
}
if let Some(value) = accounts_index_roots_stats.previous_uncleaned_roots_len {
self.previous_uncleaned_roots_len
.store(value, Ordering::Relaxed);
}
if let Some(value) = accounts_index_roots_stats.historical_roots_len {
self.historical_roots_len.store(value, Ordering::Relaxed);
}
if let Some(value) = accounts_index_roots_stats.roots_range {
self.roots_range.store(value, Ordering::Relaxed);
}
self.rooted_cleaned_count.fetch_add(
accounts_index_roots_stats.rooted_cleaned_count,
Ordering::Relaxed,

View File

@ -458,11 +458,11 @@ impl RootsTracker {
#[derive(Debug, Default)]
pub struct AccountsIndexRootsStats {
pub roots_len: usize,
pub uncleaned_roots_len: usize,
pub previous_uncleaned_roots_len: usize,
pub roots_range: u64,
pub historical_roots_len: usize,
pub roots_len: Option<usize>,
pub uncleaned_roots_len: Option<usize>,
pub previous_uncleaned_roots_len: Option<usize>,
pub roots_range: Option<u64>,
pub historical_roots_len: Option<usize>,
pub rooted_cleaned_count: usize,
pub unrooted_cleaned_count: usize,
pub clean_unref_from_storage_us: u64,
@ -1832,11 +1832,12 @@ impl<T: IndexValue> AccountsIndex<T> {
}
false
} else {
stats.roots_len = w_roots_tracker.alive_roots.len();
stats.uncleaned_roots_len = w_roots_tracker.uncleaned_roots.len();
stats.previous_uncleaned_roots_len = w_roots_tracker.previous_uncleaned_roots.len();
stats.roots_range = w_roots_tracker.alive_roots.range_width();
stats.historical_roots_len = w_roots_tracker.historical_roots.len();
stats.roots_len = Some(w_roots_tracker.alive_roots.len());
stats.uncleaned_roots_len = Some(w_roots_tracker.uncleaned_roots.len());
stats.previous_uncleaned_roots_len =
Some(w_roots_tracker.previous_uncleaned_roots.len());
stats.roots_range = Some(w_roots_tracker.alive_roots.range_width());
stats.historical_roots_len = Some(w_roots_tracker.historical_roots.len());
true
}
}