improve clean stats (#20469)
This commit is contained in:
parent
767f740305
commit
df39b37cb8
|
@ -1962,6 +1962,7 @@ impl AccountsDb {
|
||||||
|
|
||||||
let total_keys_count = pubkeys.len();
|
let total_keys_count = pubkeys.len();
|
||||||
let mut accounts_scan = Measure::start("accounts_scan");
|
let mut accounts_scan = Measure::start("accounts_scan");
|
||||||
|
let uncleaned_roots_len = self.accounts_index.uncleaned_roots_len();
|
||||||
// parallel scan the index.
|
// parallel scan the index.
|
||||||
let (mut purges_zero_lamports, purges_old_accounts) = {
|
let (mut purges_zero_lamports, purges_old_accounts) = {
|
||||||
let do_clean_scan = || {
|
let do_clean_scan = || {
|
||||||
|
@ -2161,6 +2162,7 @@ impl AccountsDb {
|
||||||
("delta_key_count", key_timings.delta_key_count, i64),
|
("delta_key_count", key_timings.delta_key_count, i64),
|
||||||
("dirty_pubkeys_count", key_timings.dirty_pubkeys_count, i64),
|
("dirty_pubkeys_count", key_timings.dirty_pubkeys_count, i64),
|
||||||
("total_keys_count", total_keys_count, i64),
|
("total_keys_count", total_keys_count, i64),
|
||||||
|
("uncleaned_roots_len", uncleaned_roots_len, i64),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5856,9 +5858,11 @@ impl AccountsDb {
|
||||||
let mut unrooted_cleaned_count = 0;
|
let mut unrooted_cleaned_count = 0;
|
||||||
let dead_slots: Vec<_> = dead_slots_iter
|
let dead_slots: Vec<_> = dead_slots_iter
|
||||||
.map(|slot| {
|
.map(|slot| {
|
||||||
if let Some(latest) = self.accounts_index.clean_dead_slot(*slot) {
|
if self
|
||||||
|
.accounts_index
|
||||||
|
.clean_dead_slot(*slot, &mut accounts_index_root_stats)
|
||||||
|
{
|
||||||
rooted_cleaned_count += 1;
|
rooted_cleaned_count += 1;
|
||||||
accounts_index_root_stats = latest;
|
|
||||||
} else {
|
} else {
|
||||||
unrooted_cleaned_count += 1;
|
unrooted_cleaned_count += 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1768,47 +1768,35 @@ impl<T: IndexValue> AccountsIndex<T> {
|
||||||
|
|
||||||
/// Remove the slot when the storage for the slot is freed
|
/// Remove the slot when the storage for the slot is freed
|
||||||
/// Accounts no longer reference this slot.
|
/// Accounts no longer reference this slot.
|
||||||
pub fn clean_dead_slot(&self, slot: Slot) -> Option<AccountsIndexRootsStats> {
|
pub fn clean_dead_slot(&self, slot: Slot, stats: &mut AccountsIndexRootsStats) -> bool {
|
||||||
let (roots_len, uncleaned_roots_len, previous_uncleaned_roots_len, roots_range) = {
|
let mut w_roots_tracker = self.roots_tracker.write().unwrap();
|
||||||
let mut w_roots_tracker = self.roots_tracker.write().unwrap();
|
let removed_from_unclean_roots = w_roots_tracker.uncleaned_roots.remove(&slot);
|
||||||
let removed_from_unclean_roots = w_roots_tracker.uncleaned_roots.remove(&slot);
|
let removed_from_previous_uncleaned_roots =
|
||||||
let removed_from_previous_uncleaned_roots =
|
w_roots_tracker.previous_uncleaned_roots.remove(&slot);
|
||||||
w_roots_tracker.previous_uncleaned_roots.remove(&slot);
|
if !w_roots_tracker.roots.remove(&slot) {
|
||||||
if !w_roots_tracker.roots.remove(&slot) {
|
if removed_from_unclean_roots {
|
||||||
if removed_from_unclean_roots {
|
error!("clean_dead_slot-removed_from_unclean_roots: {}", slot);
|
||||||
error!("clean_dead_slot-removed_from_unclean_roots: {}", slot);
|
inc_new_counter_error!("clean_dead_slot-removed_from_unclean_roots", 1, 1);
|
||||||
inc_new_counter_error!("clean_dead_slot-removed_from_unclean_roots", 1, 1);
|
|
||||||
}
|
|
||||||
if removed_from_previous_uncleaned_roots {
|
|
||||||
error!(
|
|
||||||
"clean_dead_slot-removed_from_previous_uncleaned_roots: {}",
|
|
||||||
slot
|
|
||||||
);
|
|
||||||
inc_new_counter_error!(
|
|
||||||
"clean_dead_slot-removed_from_previous_uncleaned_roots",
|
|
||||||
1,
|
|
||||||
1
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return None;
|
|
||||||
}
|
}
|
||||||
(
|
if removed_from_previous_uncleaned_roots {
|
||||||
w_roots_tracker.roots.len(),
|
error!(
|
||||||
w_roots_tracker.uncleaned_roots.len(),
|
"clean_dead_slot-removed_from_previous_uncleaned_roots: {}",
|
||||||
w_roots_tracker.previous_uncleaned_roots.len(),
|
slot
|
||||||
w_roots_tracker.roots.range_width(),
|
);
|
||||||
)
|
inc_new_counter_error!(
|
||||||
};
|
"clean_dead_slot-removed_from_previous_uncleaned_roots",
|
||||||
Some(AccountsIndexRootsStats {
|
1,
|
||||||
roots_len,
|
1
|
||||||
uncleaned_roots_len,
|
);
|
||||||
previous_uncleaned_roots_len,
|
}
|
||||||
roots_range,
|
false
|
||||||
rooted_cleaned_count: 0,
|
} else {
|
||||||
unrooted_cleaned_count: 0,
|
stats.roots_len = w_roots_tracker.roots.len();
|
||||||
clean_unref_from_storage_us: 0,
|
stats.uncleaned_roots_len = w_roots_tracker.uncleaned_roots.len();
|
||||||
clean_dead_slot_us: 0,
|
stats.previous_uncleaned_roots_len = w_roots_tracker.previous_uncleaned_roots.len();
|
||||||
})
|
stats.roots_range = w_roots_tracker.roots.range_width();
|
||||||
|
true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn min_root(&self) -> Option<Slot> {
|
pub fn min_root(&self) -> Option<Slot> {
|
||||||
|
@ -1870,7 +1858,6 @@ impl<T: IndexValue> AccountsIndex<T> {
|
||||||
self.roots_tracker.write().unwrap().roots.clear()
|
self.roots_tracker.write().unwrap().roots.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
pub fn uncleaned_roots_len(&self) -> usize {
|
pub fn uncleaned_roots_len(&self) -> usize {
|
||||||
self.roots_tracker.read().unwrap().uncleaned_roots.len()
|
self.roots_tracker.read().unwrap().uncleaned_roots.len()
|
||||||
}
|
}
|
||||||
|
@ -3274,7 +3261,7 @@ pub mod tests {
|
||||||
let index = AccountsIndex::<bool>::default_for_tests();
|
let index = AccountsIndex::<bool>::default_for_tests();
|
||||||
index.add_root(0, false);
|
index.add_root(0, false);
|
||||||
index.add_root(1, false);
|
index.add_root(1, false);
|
||||||
index.clean_dead_slot(0);
|
index.clean_dead_slot(0, &mut AccountsIndexRootsStats::default());
|
||||||
assert!(index.is_root(1));
|
assert!(index.is_root(1));
|
||||||
assert!(!index.is_root(0));
|
assert!(!index.is_root(0));
|
||||||
}
|
}
|
||||||
|
@ -3285,7 +3272,7 @@ pub mod tests {
|
||||||
let index = AccountsIndex::<bool>::default_for_tests();
|
let index = AccountsIndex::<bool>::default_for_tests();
|
||||||
index.add_root(0, false);
|
index.add_root(0, false);
|
||||||
index.add_root(1, false);
|
index.add_root(1, false);
|
||||||
index.clean_dead_slot(1);
|
index.clean_dead_slot(1, &mut AccountsIndexRootsStats::default());
|
||||||
assert!(!index.is_root(1));
|
assert!(!index.is_root(1));
|
||||||
assert!(index.is_root(0));
|
assert!(index.is_root(0));
|
||||||
}
|
}
|
||||||
|
@ -3334,7 +3321,7 @@ pub mod tests {
|
||||||
.len()
|
.len()
|
||||||
);
|
);
|
||||||
|
|
||||||
index.clean_dead_slot(1);
|
index.clean_dead_slot(1, &mut AccountsIndexRootsStats::default());
|
||||||
assert_eq!(3, index.roots_tracker.read().unwrap().roots.len());
|
assert_eq!(3, index.roots_tracker.read().unwrap().roots.len());
|
||||||
assert_eq!(2, index.roots_tracker.read().unwrap().uncleaned_roots.len());
|
assert_eq!(2, index.roots_tracker.read().unwrap().uncleaned_roots.len());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -3347,7 +3334,7 @@ pub mod tests {
|
||||||
.len()
|
.len()
|
||||||
);
|
);
|
||||||
|
|
||||||
index.clean_dead_slot(2);
|
index.clean_dead_slot(2, &mut AccountsIndexRootsStats::default());
|
||||||
assert_eq!(2, index.roots_tracker.read().unwrap().roots.len());
|
assert_eq!(2, index.roots_tracker.read().unwrap().roots.len());
|
||||||
assert_eq!(1, index.roots_tracker.read().unwrap().uncleaned_roots.len());
|
assert_eq!(1, index.roots_tracker.read().unwrap().uncleaned_roots.len());
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
|
Loading…
Reference in New Issue