bank: fix executor cache metrics
This commit is contained in:
parent
eaa52bc935
commit
3b4aad9df1
|
@ -249,24 +249,32 @@ mod executor_cache {
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
pub struct Stats {
|
pub struct Stats {
|
||||||
pub hits: u64,
|
pub hits: AtomicU64,
|
||||||
pub misses: u64,
|
pub misses: AtomicU64,
|
||||||
pub evictions: HashMap<Pubkey, u64>,
|
pub evictions: HashMap<Pubkey, u64>,
|
||||||
|
pub insertions: AtomicU64,
|
||||||
|
pub replacements: AtomicU64,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Stats {
|
impl Stats {
|
||||||
pub fn submit(&self, slot: Slot) {
|
pub fn submit(&self, slot: Slot) {
|
||||||
|
let hits = self.hits.load(Relaxed);
|
||||||
|
let misses = self.misses.load(Relaxed);
|
||||||
|
let insertions = self.insertions.load(Relaxed);
|
||||||
|
let replacements = self.replacements.load(Relaxed);
|
||||||
let evictions: u64 = self.evictions.values().sum();
|
let evictions: u64 = self.evictions.values().sum();
|
||||||
datapoint_info!(
|
datapoint_info!(
|
||||||
"bank-executor-cache-stats",
|
"bank-executor-cache-stats",
|
||||||
("slot", slot, i64),
|
("slot", slot, i64),
|
||||||
("hits", self.hits, i64),
|
("hits", hits, i64),
|
||||||
("misses", self.misses, i64),
|
("misses", misses, i64),
|
||||||
("evictions", evictions, i64),
|
("evictions", evictions, i64),
|
||||||
|
("insertions", insertions, i64),
|
||||||
|
("replacements", replacements, i64),
|
||||||
);
|
);
|
||||||
debug!(
|
debug!(
|
||||||
"Executor Cache Stats -- Hits: {}, Misses: {}, Evictions: {}",
|
"Executor Cache Stats -- Hits: {}, Misses: {}, Evictions: {}, Insertions: {}, Replacements: {}",
|
||||||
self.hits, self.misses, evictions
|
hits, misses, evictions, insertions, replacements,
|
||||||
);
|
);
|
||||||
if log_enabled!(log::Level::Trace) && !self.evictions.is_empty() {
|
if log_enabled!(log::Level::Trace) && !self.evictions.is_empty() {
|
||||||
let mut evictions = self.evictions.iter().collect::<Vec<_>>();
|
let mut evictions = self.evictions.iter().collect::<Vec<_>>();
|
||||||
|
@ -378,10 +386,14 @@ impl CachedExecutors {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get(&self, pubkey: &Pubkey) -> Option<Arc<dyn Executor>> {
|
fn get(&self, pubkey: &Pubkey) -> Option<Arc<dyn Executor>> {
|
||||||
self.executors.get(pubkey).map(|entry| {
|
if let Some(entry) = self.executors.get(pubkey) {
|
||||||
|
self.stats.hits.fetch_add(1, Relaxed);
|
||||||
entry.epoch_count.fetch_add(1, Relaxed);
|
entry.epoch_count.fetch_add(1, Relaxed);
|
||||||
entry.executor.clone()
|
Some(entry.executor.clone())
|
||||||
})
|
} else {
|
||||||
|
self.stats.misses.fetch_add(1, Relaxed);
|
||||||
|
None
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn put(&mut self, executors: &[(&Pubkey, Arc<dyn Executor>)]) {
|
fn put(&mut self, executors: &[(&Pubkey, Arc<dyn Executor>)]) {
|
||||||
|
@ -389,12 +401,12 @@ impl CachedExecutors {
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|(key, executor)| {
|
.filter_map(|(key, executor)| {
|
||||||
if let Some(mut entry) = self.executors.remove(key) {
|
if let Some(mut entry) = self.executors.remove(key) {
|
||||||
saturating_add_assign!(self.stats.hits, 1);
|
self.stats.replacements.fetch_add(1, Relaxed);
|
||||||
entry.executor = executor.clone();
|
entry.executor = executor.clone();
|
||||||
let _ = self.executors.insert(**key, entry);
|
let _ = self.executors.insert(**key, entry);
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
saturating_add_assign!(self.stats.misses, 1);
|
self.stats.insertions.fetch_add(1, Relaxed);
|
||||||
Some((*key, executor))
|
Some((*key, executor))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue