AcctIdx: remove -> evict (#23775)

This commit is contained in:
Jeff Washington (jwash) 2022-03-18 17:13:21 -05:00 committed by GitHub
parent 71ea05c176
commit df29276eb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 15 deletions

View File

@ -38,14 +38,14 @@ pub struct BucketMapHolderStats {
pub count_in_mem: AtomicUsize, pub count_in_mem: AtomicUsize,
pub per_bucket_count: Vec<AtomicUsize>, pub per_bucket_count: Vec<AtomicUsize>,
pub flush_entries_updated_on_disk: AtomicU64, pub flush_entries_updated_on_disk: AtomicU64,
pub flush_entries_removed_from_mem: AtomicU64, pub flush_entries_evicted_from_mem: AtomicU64,
pub active_threads: AtomicU64, pub active_threads: AtomicU64,
pub get_range_us: AtomicU64, pub get_range_us: AtomicU64,
last_age: AtomicU8, last_age: AtomicU8,
last_ages_flushed: AtomicU64, last_ages_flushed: AtomicU64,
pub flush_scan_us: AtomicU64, pub flush_scan_us: AtomicU64,
pub flush_update_us: AtomicU64, pub flush_update_us: AtomicU64,
pub flush_remove_us: AtomicU64, pub flush_evict_us: AtomicU64,
pub flush_grow_us: AtomicU64, pub flush_grow_us: AtomicU64,
last_was_startup: AtomicBool, last_was_startup: AtomicBool,
last_time: AtomicInterval, last_time: AtomicInterval,
@ -345,8 +345,8 @@ impl BucketMapHolderStats {
i64 i64
), ),
( (
"flush_remove_us", "flush_evict_us",
self.flush_remove_us.swap(0, Ordering::Relaxed), self.flush_evict_us.swap(0, Ordering::Relaxed),
i64 i64
), ),
( (
@ -438,8 +438,8 @@ impl BucketMapHolderStats {
i64 i64
), ),
( (
"flush_entries_removed_from_mem", "flush_entries_evicted_from_mem",
self.flush_entries_removed_from_mem self.flush_entries_evicted_from_mem
.swap(0, Ordering::Relaxed), .swap(0, Ordering::Relaxed),
i64 i64
), ),

View File

@ -933,7 +933,7 @@ impl<T: IndexValue> InMemAccountsIndex<T> {
let startup = self.storage.get_startup(); let startup = self.storage.get_startup();
if !iterate_for_age && !startup { if !iterate_for_age && !startup {
// no need to age, so no need to flush this bucket // no need to age, so no need to flush this bucket
// but, at startup we want to remove from buckets as fast as possible if any items exist // but, at startup we want to evict from buckets as fast as possible if any items exist
return; return;
} }
@ -970,7 +970,7 @@ impl<T: IndexValue> InMemAccountsIndex<T> {
mse.stop(); mse.stop();
flush_should_evict_us += mse.as_us(); flush_should_evict_us += mse.as_us();
if !evict_for_age && !Self::random_chance_of_eviction() { if !evict_for_age && !Self::random_chance_of_eviction() {
// not planning to remove this item from memory now, so don't write it to disk yet // not planning to evict this item from memory now, so don't write it to disk yet
continue; continue;
} }
@ -1034,7 +1034,7 @@ impl<T: IndexValue> InMemAccountsIndex<T> {
let m = Measure::start("flush_evict"); let m = Measure::start("flush_evict");
self.evict_from_cache(evictions, current_age, startup, false); self.evict_from_cache(evictions, current_age, startup, false);
self.evict_from_cache(evictions_random, current_age, startup, true); self.evict_from_cache(evictions_random, current_age, startup, true);
Self::update_time_stat(&self.stats().flush_remove_us, m); Self::update_time_stat(&self.stats().flush_evict_us, m);
if iterate_for_age { if iterate_for_age {
// completed iteration of the buckets at the current age // completed iteration of the buckets at the current age
@ -1054,7 +1054,7 @@ impl<T: IndexValue> InMemAccountsIndex<T> {
}); });
} }
// remove keys in 'evictions' from in-mem cache, likely due to age // evict keys in 'evictions' from in-mem cache, likely due to age
fn evict_from_cache( fn evict_from_cache(
&self, &self,
mut evictions: Vec<Pubkey>, mut evictions: Vec<Pubkey>,
@ -1092,7 +1092,7 @@ impl<T: IndexValue> InMemAccountsIndex<T> {
} }
} }
let mut removed = 0; let mut evicted = 0;
// consider chunking these so we don't hold the write lock too long // consider chunking these so we don't hold the write lock too long
let mut map = self.map().write().unwrap(); let mut map = self.map().write().unwrap();
for k in evictions { for k in evictions {
@ -1120,8 +1120,8 @@ impl<T: IndexValue> InMemAccountsIndex<T> {
continue; continue;
} }
// all conditions for removing succeeded, so really remove item from in-mem cache // all conditions for removing succeeded, so really evict item from in-mem cache
removed += 1; evicted += 1;
occupied.remove(); occupied.remove();
} }
} }
@ -1130,8 +1130,8 @@ impl<T: IndexValue> InMemAccountsIndex<T> {
} }
drop(map); drop(map);
self.stats() self.stats()
.insert_or_delete_mem_count(false, self.bin, removed); .insert_or_delete_mem_count(false, self.bin, evicted);
Self::update_stat(&self.stats().flush_entries_removed_from_mem, removed as u64); Self::update_stat(&self.stats().flush_entries_evicted_from_mem, evicted as u64);
} }
pub fn stats(&self) -> &BucketMapHolderStats { pub fn stats(&self) -> &BucketMapHolderStats {