From 89ba3ff1392e08c293275629de902e3f2c538d85 Mon Sep 17 00:00:00 2001 From: "Jeff Washington (jwash)" Date: Tue, 22 Mar 2022 09:19:38 -0500 Subject: [PATCH] log fail to evict (#23815) --- runtime/src/bucket_map_holder_stats.rs | 6 ++++++ runtime/src/in_mem_accounts_index.rs | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/runtime/src/bucket_map_holder_stats.rs b/runtime/src/bucket_map_holder_stats.rs index 1a0cd118eb..713318ce94 100644 --- a/runtime/src/bucket_map_holder_stats.rs +++ b/runtime/src/bucket_map_holder_stats.rs @@ -29,6 +29,7 @@ pub struct BucketMapHolderStats { pub updates_in_mem: AtomicU64, pub items: AtomicU64, pub items_us: AtomicU64, + pub failed_to_evict: AtomicU64, pub keys: AtomicU64, pub deletes: AtomicU64, pub inserts: AtomicU64, @@ -319,6 +320,11 @@ impl BucketMapHolderStats { self.entry_missing_us.swap(0, Ordering::Relaxed), i64 ), + ( + "failed_to_evict", + self.failed_to_evict.swap(0, Ordering::Relaxed), + i64 + ), ( "updates_in_mem", self.updates_in_mem.swap(0, Ordering::Relaxed), diff --git a/runtime/src/in_mem_accounts_index.rs b/runtime/src/in_mem_accounts_index.rs index 121e29e7fb..72fe753c70 100644 --- a/runtime/src/in_mem_accounts_index.rs +++ b/runtime/src/in_mem_accounts_index.rs @@ -1104,6 +1104,8 @@ impl InMemAccountsIndex { return; } + let mut failed = 0; + // skip any keys that are held in memory because of ranges being held let ranges = self.cache_ranges_held.read().unwrap().clone(); if !ranges.is_empty() { @@ -1118,6 +1120,7 @@ impl InMemAccountsIndex { } }); if !move_age.is_empty() { + failed += move_age.len(); self.move_ages_to_future(next_age_on_failure, current_age, &move_age); } } @@ -1131,6 +1134,7 @@ impl InMemAccountsIndex { let v = occupied.get(); if Arc::strong_count(v) > 1 { // someone is holding the value arc's ref count and could modify it, so do not evict + failed += 1; v.try_exchange_age(next_age_on_failure, current_age); continue; } @@ -1142,11 +1146,13 @@ impl InMemAccountsIndex { // marked dirty or bumped in age after we looked above // these evictions will be handled in later passes (at later ages) // but, at startup, everything is ready to age out if it isn't dirty + failed += 1; continue; } if stop_evictions_changes_at_start != self.get_stop_evictions_changes() { // ranges were changed + failed += 1; v.try_exchange_age(next_age_on_failure, current_age); continue; } @@ -1163,6 +1169,7 @@ impl InMemAccountsIndex { self.stats() .insert_or_delete_mem_count(false, self.bin, evicted); Self::update_stat(&self.stats().flush_entries_evicted_from_mem, evicted as u64); + Self::update_stat(&self.stats().failed_to_evict, failed as u64); } pub fn stats(&self) -> &BucketMapHolderStats {