Skip to content
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
6 changes: 6 additions & 0 deletions accounts-db/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8239,6 +8239,7 @@ impl AccountsDb {
read_only_cache_misses,
read_only_cache_evicts,
read_only_cache_load_us,
read_only_cache_evict_us,
) = self.read_only_accounts_cache.get_and_reset_stats();
datapoint_info!(
"accounts_db_store_timings",
Expand Down Expand Up @@ -8310,6 +8311,11 @@ impl AccountsDb {
read_only_cache_load_us,
i64
),
(
"read_only_accounts_cache_evict_us",
read_only_cache_evict_us,
i64
),
(
"calc_stored_meta_us",
self.stats.calc_stored_meta.swap(0, Ordering::Relaxed),
Expand Down
26 changes: 16 additions & 10 deletions accounts-db/src/read_only_accounts_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ struct ReadOnlyCacheStats {
misses: AtomicU64,
evicts: AtomicU64,
load_us: AtomicU64,
evict_us: AtomicU64,
}

impl ReadOnlyCacheStats {
Expand All @@ -44,15 +45,17 @@ impl ReadOnlyCacheStats {
self.misses.store(0, Ordering::Relaxed);
self.evicts.store(0, Ordering::Relaxed);
self.load_us.store(0, Ordering::Relaxed);
self.evict_us.store(0, Ordering::Relaxed);
}

fn get_and_reset_stats(&self) -> (u64, u64, u64, u64) {
fn get_and_reset_stats(&self) -> (u64, u64, u64, u64, u64) {
let hits = self.hits.swap(0, Ordering::Relaxed);
let misses = self.misses.swap(0, Ordering::Relaxed);
let evicts = self.evicts.swap(0, Ordering::Relaxed);
let load_us = self.load_us.swap(0, Ordering::Relaxed);
let evict_us = self.evict_us.swap(0, Ordering::Relaxed);

(hits, misses, evicts, load_us)
(hits, misses, evicts, load_us, evict_us)
}
}

Expand Down Expand Up @@ -162,14 +165,17 @@ impl ReadOnlyAccountsCache {
};
// Evict entries from the front of the queue.
let mut num_evicts = 0;
while self.data_size.load(Ordering::Relaxed) > self.max_data_size {
let Some(&(pubkey, slot)) = self.queue.lock().unwrap().get_first() else {
break;
};
num_evicts += 1;
self.remove(pubkey, slot);
}
let (_, evict_us) = measure_us!({
while self.data_size.load(Ordering::Relaxed) > self.max_data_size {
let Some(&(pubkey, slot)) = self.queue.lock().unwrap().get_first() else {
break;
};
num_evicts += 1;
self.remove(pubkey, slot);
}
});
self.stats.evicts.fetch_add(num_evicts, Ordering::Relaxed);
self.stats.evict_us.fetch_add(evict_us, Ordering::Relaxed);
}

/// true if any pubkeys could have ever been stored into the cache at `slot`
Expand Down Expand Up @@ -208,7 +214,7 @@ impl ReadOnlyAccountsCache {
self.data_size.load(Ordering::Relaxed)
}

pub(crate) fn get_and_reset_stats(&self) -> (u64, u64, u64, u64) {
pub(crate) fn get_and_reset_stats(&self) -> (u64, u64, u64, u64, u64) {
self.stats.get_and_reset_stats()
}
}
Expand Down