Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AcctIdx: add flush remove stat #20625

Merged
merged 1 commit into from
Oct 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions runtime/src/bucket_map_holder_stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ pub struct BucketMapHolderStats {
pub count_in_mem: AtomicU64,
pub per_bucket_count: Vec<AtomicU64>,
pub flush_entries_updated_on_disk: AtomicU64,
pub flush_entries_removed_from_mem: AtomicU64,
pub active_threads: AtomicU64,
pub get_range_us: AtomicU64,
last_age: AtomicU8,
Expand Down Expand Up @@ -66,13 +67,17 @@ impl BucketMapHolderStats {
}

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);
if insert {
self.count_in_mem.fetch_add(1, Ordering::Relaxed);
per_bucket.map(|count| count.fetch_add(1, Ordering::Relaxed));
self.count_in_mem.fetch_add(count, Ordering::Relaxed);
per_bucket.map(|stat| stat.fetch_add(count, Ordering::Relaxed));
} else {
self.count_in_mem.fetch_sub(1, Ordering::Relaxed);
per_bucket.map(|count| count.fetch_sub(1, Ordering::Relaxed));
self.count_in_mem.fetch_sub(count, Ordering::Relaxed);
per_bucket.map(|stat| stat.fetch_sub(count, Ordering::Relaxed));
}
}

Expand Down Expand Up @@ -364,6 +369,12 @@ impl BucketMapHolderStats {
.swap(0, Ordering::Relaxed),
i64
),
(
"flush_entries_removed_from_mem",
self.flush_entries_removed_from_mem
.swap(0, Ordering::Relaxed),
i64
),
);
}
}
7 changes: 6 additions & 1 deletion runtime/src/in_mem_accounts_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,7 @@ impl<T: IndexValue> InMemAccountsIndex<T> {
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
let mut map = self.map().write().unwrap();
for k in removes {
Expand Down Expand Up @@ -815,10 +816,14 @@ impl<T: IndexValue> InMemAccountsIndex<T> {
}

// 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();
}
}
self.stats()
.insert_or_delete_mem_count(false, self.bin, removed);
Self::update_stat(&self.stats().flush_entries_removed_from_mem, removed);

completed_scan
}

Expand Down