From 3fae579db4b36502c5db63f1ac8b76f9769ddfa5 Mon Sep 17 00:00:00 2001 From: brooks Date: Tue, 10 Sep 2024 13:37:28 -0400 Subject: [PATCH] Removes slot param from shrink_storage() --- accounts-db/src/accounts_db.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/accounts-db/src/accounts_db.rs b/accounts-db/src/accounts_db.rs index 169e3d498f3fa3..06a6235654c3fd 100644 --- a/accounts-db/src/accounts_db.rs +++ b/accounts-db/src/accounts_db.rs @@ -4353,7 +4353,9 @@ impl AccountsDb { ); } - fn do_shrink_slot_store(&self, slot: Slot, store: &AccountStorageEntry) { + /// Shrinks `store` by rewriting the alive accounts to a new storage + fn shrink_storage(&self, store: &AccountStorageEntry) { + let slot = store.slot(); if self.accounts_cache.contains(slot) { // It is not correct to shrink a slot while it is in the write cache until flush is complete and the slot is removed from the write cache. // There can exist a window after a slot is made a root and before the write cache flushing for that slot begins and then completes. @@ -4555,10 +4557,9 @@ impl AccountsDb { .storage .get_slot_storage_entry_shrinking_in_progress_ok(slot) { - if !Self::is_shrinking_productive(slot, &store) { - return; + if Self::is_shrinking_productive(slot, &store) { + self.shrink_storage(&store) } - self.do_shrink_slot_store(slot, &store) } } @@ -5104,7 +5105,7 @@ impl AccountsDb { .fetch_add(1, Ordering::Relaxed); } let mut measure = Measure::start("shrink_candidate_slots-ms"); - self.do_shrink_slot_store(slot, &slot_shrink_candidate); + self.shrink_storage(&slot_shrink_candidate); measure.stop(); inc_new_counter_info!("shrink_candidate_slots-ms", measure.as_ms() as usize); });