AcctIdx: add flush remove stat (#20625)
This commit is contained in:
parent
06cad19c91
commit
7631011d8c
|
@ -34,6 +34,7 @@ pub struct BucketMapHolderStats {
|
||||||
pub count_in_mem: AtomicU64,
|
pub count_in_mem: AtomicU64,
|
||||||
pub per_bucket_count: Vec<AtomicU64>,
|
pub per_bucket_count: Vec<AtomicU64>,
|
||||||
pub flush_entries_updated_on_disk: AtomicU64,
|
pub flush_entries_updated_on_disk: AtomicU64,
|
||||||
|
pub flush_entries_removed_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,
|
||||||
|
@ -66,13 +67,17 @@ impl BucketMapHolderStats {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn insert_or_delete_mem(&self, insert: bool, bin: usize) {
|
pub fn insert_or_delete_mem(&self, insert: bool, bin: usize) {
|
||||||
|
self.insert_or_delete_mem_count(insert, bin, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn insert_or_delete_mem_count(&self, insert: bool, bin: usize, count: u64) {
|
||||||
let per_bucket = self.per_bucket_count.get(bin);
|
let per_bucket = self.per_bucket_count.get(bin);
|
||||||
if insert {
|
if insert {
|
||||||
self.count_in_mem.fetch_add(1, Ordering::Relaxed);
|
self.count_in_mem.fetch_add(count, Ordering::Relaxed);
|
||||||
per_bucket.map(|count| count.fetch_add(1, Ordering::Relaxed));
|
per_bucket.map(|stat| stat.fetch_add(count, Ordering::Relaxed));
|
||||||
} else {
|
} else {
|
||||||
self.count_in_mem.fetch_sub(1, Ordering::Relaxed);
|
self.count_in_mem.fetch_sub(count, Ordering::Relaxed);
|
||||||
per_bucket.map(|count| count.fetch_sub(1, Ordering::Relaxed));
|
per_bucket.map(|stat| stat.fetch_sub(count, Ordering::Relaxed));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -364,6 +369,12 @@ impl BucketMapHolderStats {
|
||||||
.swap(0, Ordering::Relaxed),
|
.swap(0, Ordering::Relaxed),
|
||||||
i64
|
i64
|
||||||
),
|
),
|
||||||
|
(
|
||||||
|
"flush_entries_removed_from_mem",
|
||||||
|
self.flush_entries_removed_from_mem
|
||||||
|
.swap(0, Ordering::Relaxed),
|
||||||
|
i64
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -778,6 +778,7 @@ impl<T: IndexValue> InMemAccountsIndex<T> {
|
||||||
return false; // range said to hold 'all', so not completed
|
return false; // range said to hold 'all', so not completed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mut removed = 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 removes {
|
for k in removes {
|
||||||
|
@ -815,10 +816,14 @@ impl<T: IndexValue> InMemAccountsIndex<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// all conditions for removing succeeded, so really remove item from in-mem cache
|
// all conditions for removing succeeded, so really remove item from in-mem cache
|
||||||
self.stats().insert_or_delete_mem(false, self.bin);
|
removed += 1;
|
||||||
occupied.remove();
|
occupied.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
self.stats()
|
||||||
|
.insert_or_delete_mem_count(false, self.bin, removed);
|
||||||
|
Self::update_stat(&self.stats().flush_entries_removed_from_mem, removed);
|
||||||
|
|
||||||
completed_scan
|
completed_scan
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue