From e33604c24ad13b0deb97b3de929359d9bb2b2190 Mon Sep 17 00:00:00 2001 From: Dmitri Makarov Date: Tue, 1 Oct 2024 18:33:18 -0400 Subject: [PATCH] Remove redundancy --- accounts-db/src/accounts_db.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/accounts-db/src/accounts_db.rs b/accounts-db/src/accounts_db.rs index 7acfec86ede335..d515d17bd153b4 100644 --- a/accounts-db/src/accounts_db.rs +++ b/accounts-db/src/accounts_db.rs @@ -5088,19 +5088,16 @@ impl AccountsDb { } }); - let mut ancient_slots_added = 0; // If there are too few slots to shrink, add an ancient slot // for shrinking. if shrink_slots.len() < SHRINK_INSERT_ANCIENT_THRESHOLD { - let mut ancients = self.best_ancient_slots_to_shrink.write().unwrap(); - if let Some((slot, capacity)) = ancients.first_mut() { + let ancients = self.best_ancient_slots_to_shrink.read().unwrap(); + if let Some((slot, capacity)) = ancients.first() { if let Some(store) = self.storage.get_slot_storage_entry(*slot) { if !shrink_slots.contains(slot) && *capacity == store.capacity() && Self::is_candidate_for_shrink(self, &store) { - *capacity = 0; - ancient_slots_added += 1; let ancient_bytes_added_to_shrink = store.alive_bytes() as u64; shrink_slots.insert(*slot, store); self.shrink_stats @@ -5108,7 +5105,7 @@ impl AccountsDb { .fetch_add(ancient_bytes_added_to_shrink, Ordering::Relaxed); self.shrink_stats .ancient_slots_added_to_shrink - .fetch_add(ancient_slots_added, Ordering::Relaxed); + .fetch_add(1, Ordering::Relaxed); } } }