Skip to content

Commit

Permalink
clean doesn't try to remove older entries on 1 elem slot list (#2308)
Browse files Browse the repository at this point in the history
* clean doesn't try to remove older entries on 1 elem slot list

* move useless
  • Loading branch information
jeffwashington authored Jul 30, 2024
1 parent 83e967a commit fa9205e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
26 changes: 24 additions & 2 deletions accounts-db/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1937,6 +1937,7 @@ struct CleanAccountsStats {
remove_dead_accounts_remove_us: AtomicU64,
remove_dead_accounts_shrink_us: AtomicU64,
clean_stored_dead_slots_us: AtomicU64,
uncleaned_roots_slot_list_1: AtomicU64,
}

impl CleanAccountsStats {
Expand Down Expand Up @@ -3282,8 +3283,15 @@ impl AccountsDb {
{
assert!(slot <= &max_clean_root_inclusive);
}
purges_old_accounts.push(*candidate);
useless = false;
if slot_list.len() > 1 {
// no need to purge old accounts if there is only 1 slot in the slot list
purges_old_accounts.push(*candidate);
useless = false;
} else {
self.clean_accounts_stats
.uncleaned_roots_slot_list_1
.fetch_add(1, Ordering::Relaxed);
}
}
}
None => {
Expand Down Expand Up @@ -3497,6 +3505,13 @@ impl AccountsDb {
),
("scan_missing", missing_accum.load(Ordering::Relaxed), i64),
("uncleaned_roots_len", uncleaned_roots.len(), i64),
(
"uncleaned_roots_slot_list_1",
self.clean_accounts_stats
.uncleaned_roots_slot_list_1
.swap(0, Ordering::Relaxed),
i64
),
(
"clean_old_root_us",
self.clean_accounts_stats
Expand Down Expand Up @@ -3544,6 +3559,13 @@ impl AccountsDb {
self.accounts_index.roots_added.swap(0, Ordering::Relaxed),
i64
),
(
"purge_older_root_entries_one_slot_list",
self.accounts_index
.purge_older_root_entries_one_slot_list
.swap(0, Ordering::Relaxed),
i64
),
(
"roots_removed",
self.accounts_index.roots_removed.swap(0, Ordering::Relaxed),
Expand Down
7 changes: 7 additions & 0 deletions accounts-db/src/accounts_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,8 @@ pub struct AccountsIndex<T: IndexValue, U: DiskIndexValue + From<T> + Into<T>> {
/// when a scan's accumulated data exceeds this limit, abort the scan
pub scan_results_limit_bytes: Option<usize>,

pub purge_older_root_entries_one_slot_list: AtomicUsize,

/// # roots added since last check
pub roots_added: AtomicUsize,
/// # roots removed since last check
Expand All @@ -690,6 +692,7 @@ impl<T: IndexValue, U: DiskIndexValue + From<T> + Into<T>> AccountsIndex<T, U> {
.and_then(|config| config.scan_results_limit_bytes);
let (account_maps, bin_calculator, storage) = Self::allocate_accounts_index(config, exit);
Self {
purge_older_root_entries_one_slot_list: AtomicUsize::default(),
account_maps,
bin_calculator,
program_id_index: SecondaryIndex::<RwLockSecondaryIndexEntry>::new(
Expand Down Expand Up @@ -1817,6 +1820,10 @@ impl<T: IndexValue, U: DiskIndexValue + From<T> + Into<T>> AccountsIndex<T, U> {
reclaims: &mut SlotList<T>,
max_clean_root_inclusive: Option<Slot>,
) {
if slot_list.len() <= 1 {
self.purge_older_root_entries_one_slot_list
.fetch_add(1, Ordering::Relaxed);
}
let newest_root_in_slot_list;
let max_clean_root_inclusive = {
let roots_tracker = &self.roots_tracker.read().unwrap();
Expand Down

0 comments on commit fa9205e

Please sign in to comment.