clean:clone uncleaned_roots for loop (#20714)

This commit is contained in:
Jeff Washington (jwash)
2021-10-15 13:18:00 -05:00
committed by GitHub
parent 9543fd9cdd
commit 6d7da6dbee
2 changed files with 6 additions and 1 deletions

View File

@ -2002,6 +2002,7 @@ impl AccountsDb {
let total_keys_count = pubkeys.len();
let mut accounts_scan = Measure::start("accounts_scan");
let uncleaned_roots = self.accounts_index.clone_uncleaned_roots();
let uncleaned_roots_len = self.accounts_index.uncleaned_roots_len();
let found_not_zero_accum = AtomicU64::new(0);
let not_found_on_fork_accum = AtomicU64::new(0);
@ -2036,7 +2037,7 @@ impl AccountsDb {
let slot = *slot;
drop(locked_entry);
if self.accounts_index.is_uncleaned_root(slot) {
if uncleaned_roots.contains(&slot) {
// Assertion enforced by `accounts_index.get()`, the latest slot
// will not be greater than the given `max_clean_root`
if let Some(max_clean_root) = max_clean_root {

View File

@ -1865,6 +1865,10 @@ impl<T: IndexValue> AccountsIndex<T> {
self.roots_tracker.write().unwrap().roots.clear()
}
pub fn clone_uncleaned_roots(&self) -> HashSet<Slot> {
self.roots_tracker.read().unwrap().uncleaned_roots.clone()
}
pub fn uncleaned_roots_len(&self) -> usize {
self.roots_tracker.read().unwrap().uncleaned_roots.len()
}