shrink ancient append vecs at 90% (#28736)

This commit is contained in:
Jeff Washington (jwash) 2022-11-10 20:05:34 -08:00 committed by GitHub
parent 4142f42319
commit b2ece6368f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -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