From 6d7da6dbee3e58aa302da94e08edad6c6692a400 Mon Sep 17 00:00:00 2001 From: "Jeff Washington (jwash)" <75863576+jeffwashington@users.noreply.github.com> Date: Fri, 15 Oct 2021 13:18:00 -0500 Subject: [PATCH] clean:clone uncleaned_roots for loop (#20714) --- runtime/src/accounts_db.rs | 3 ++- runtime/src/accounts_index.rs | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/runtime/src/accounts_db.rs b/runtime/src/accounts_db.rs index dae1c653ac..3f618b713f 100644 --- a/runtime/src/accounts_db.rs +++ b/runtime/src/accounts_db.rs @@ -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 { diff --git a/runtime/src/accounts_index.rs b/runtime/src/accounts_index.rs index 89b86dbf81..e6ec29b249 100644 --- a/runtime/src/accounts_index.rs +++ b/runtime/src/accounts_index.rs @@ -1865,6 +1865,10 @@ impl AccountsIndex { self.roots_tracker.write().unwrap().roots.clear() } + pub fn clone_uncleaned_roots(&self) -> HashSet { + self.roots_tracker.read().unwrap().uncleaned_roots.clone() + } + pub fn uncleaned_roots_len(&self) -> usize { self.roots_tracker.read().unwrap().uncleaned_roots.len() }