Skip to content

Commit

Permalink
Remove redundancy
Browse files Browse the repository at this point in the history
  • Loading branch information
dmakarov committed Oct 1, 2024
1 parent f865192 commit b9402b7
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions accounts-db/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5124,27 +5124,24 @@ 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
.ancient_bytes_added_to_shrink
.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);
}
}
}
Expand Down

0 comments on commit b9402b7

Please sign in to comment.