make max_roots_inclusive clear (#22942)

This commit is contained in:
Jeff Washington (jwash) 2022-02-07 13:26:53 -06:00 committed by GitHub
parent 514aab46d9
commit a160fc30f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 11 deletions

View File

@ -2000,7 +2000,7 @@ impl AccountsDb {
timings: &mut CleanKeyTimings, timings: &mut CleanKeyTimings,
) -> Vec<Pubkey> { ) -> Vec<Pubkey> {
let mut dirty_store_processing_time = Measure::start("dirty_store_processing"); let mut dirty_store_processing_time = Measure::start("dirty_store_processing");
let max_slot = max_clean_root.unwrap_or_else(|| self.accounts_index.max_root()); let max_slot = max_clean_root.unwrap_or_else(|| self.accounts_index.max_root_inclusive());
let mut dirty_stores = Vec::with_capacity(self.dirty_stores.len()); let mut dirty_stores = Vec::with_capacity(self.dirty_stores.len());
self.dirty_stores.retain(|(slot, _store_id), store| { self.dirty_stores.retain(|(slot, _store_id), store| {
if *slot > max_slot { if *slot > max_slot {

View File

@ -615,7 +615,7 @@ impl RollingBitField {
#[derive(Debug)] #[derive(Debug)]
pub struct RootsTracker { pub struct RootsTracker {
roots: RollingBitField, roots: RollingBitField,
max_root: Slot, max_root_inclusive: Slot,
uncleaned_roots: HashSet<Slot>, uncleaned_roots: HashSet<Slot>,
previous_uncleaned_roots: HashSet<Slot>, previous_uncleaned_roots: HashSet<Slot>,
} }
@ -633,7 +633,7 @@ impl RootsTracker {
pub fn new(max_width: u64) -> Self { pub fn new(max_width: u64) -> Self {
Self { Self {
roots: RollingBitField::new(max_width), roots: RollingBitField::new(max_width),
max_root: 0, max_root_inclusive: 0,
uncleaned_roots: HashSet::new(), uncleaned_roots: HashSet::new(),
previous_uncleaned_roots: HashSet::new(), previous_uncleaned_roots: HashSet::new(),
} }
@ -958,10 +958,10 @@ impl<T: IndexValue> AccountsIndex<T> {
// the `ongoing_scan_roots` lock is held, // the `ongoing_scan_roots` lock is held,
// make sure inverse doesn't happen to avoid // make sure inverse doesn't happen to avoid
// deadlock // deadlock
let max_root = self.max_root(); let max_root_inclusive = self.max_root_inclusive();
*w_ongoing_scan_roots.entry(max_root).or_default() += 1; *w_ongoing_scan_roots.entry(max_root_inclusive).or_default() += 1;
max_root max_root_inclusive
}; };
// First we show that for any bank `B` that is a descendant of // First we show that for any bank `B` that is a descendant of
@ -1793,7 +1793,7 @@ impl<T: IndexValue> AccountsIndex<T> {
let roots_tracker = &self.roots_tracker.read().unwrap(); let roots_tracker = &self.roots_tracker.read().unwrap();
let newest_root_in_slot_list = let newest_root_in_slot_list =
Self::get_newest_root_in_slot_list(&roots_tracker.roots, slot_list, max_clean_root); Self::get_newest_root_in_slot_list(&roots_tracker.roots, slot_list, max_clean_root);
let max_clean_root = max_clean_root.unwrap_or(roots_tracker.max_root); let max_clean_root = max_clean_root.unwrap_or(roots_tracker.max_root_inclusive);
slot_list.retain(|(slot, value)| { slot_list.retain(|(slot, value)| {
let should_purge = let should_purge =
@ -1874,8 +1874,8 @@ impl<T: IndexValue> AccountsIndex<T> {
w_roots_tracker.uncleaned_roots.insert(slot); w_roots_tracker.uncleaned_roots.insert(slot);
} }
// `AccountsDb::flush_accounts_cache()` relies on roots being added in order // `AccountsDb::flush_accounts_cache()` relies on roots being added in order
assert!(slot >= w_roots_tracker.max_root); assert!(slot >= w_roots_tracker.max_root_inclusive);
w_roots_tracker.max_root = slot; w_roots_tracker.max_root_inclusive = slot;
} }
pub fn add_uncleaned_roots<I>(&self, roots: I) pub fn add_uncleaned_roots<I>(&self, roots: I)
@ -1886,8 +1886,8 @@ impl<T: IndexValue> AccountsIndex<T> {
w_roots_tracker.uncleaned_roots.extend(roots); w_roots_tracker.uncleaned_roots.extend(roots);
} }
pub fn max_root(&self) -> Slot { pub fn max_root_inclusive(&self) -> Slot {
self.roots_tracker.read().unwrap().max_root self.roots_tracker.read().unwrap().max_root_inclusive
} }
/// Remove the slot when the storage for the slot is freed /// Remove the slot when the storage for the slot is freed