From b2ece6368f4e2c2d63225c2fd30a0a19e7605ccd Mon Sep 17 00:00:00 2001 From: "Jeff Washington (jwash)" Date: Thu, 10 Nov 2022 20:05:34 -0800 Subject: [PATCH] shrink ancient append vecs at 90% (#28736) --- runtime/src/accounts_db.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/runtime/src/accounts_db.rs b/runtime/src/accounts_db.rs index 305c8b7eb0..357fae4ccb 100644 --- a/runtime/src/accounts_db.rs +++ b/runtime/src/accounts_db.rs @@ -4429,7 +4429,13 @@ impl AccountsDb { // randomly shrink ancient slots // this exercises the ancient shrink code more often - let is_candidate = self.is_candidate_for_shrink(storage, true); + let written_bytes = storage.written_bytes(); + let is_candidate = if written_bytes > 0 { + let alive_ratio = (storage.alive_bytes() as u64) * 100 / written_bytes; + alive_ratio < 90 + } else { + false + }; if is_candidate || (can_randomly_shrink && thread_rng().gen_range(0, 100) == 0) { // we are a candidate for shrink, so either append us to the previous append vec // or recreate us as a new append vec and eliminate the dead accounts