Skip to content

Commit

Permalink
AcctIdx: add flush remove stat (solana-labs#20625)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffwashington authored Oct 12, 2021
1 parent 06cad19 commit 7631011
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
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

0 comments on commit 7631011

Please sign in to comment.