fix initial massive metrics spike (#21304)
This commit is contained in:
committed by
GitHub
parent
91fe1278f1
commit
83de2f7376
@ -1,6 +1,6 @@
|
||||
use crate::accounts_index::IndexValue;
|
||||
use crate::bucket_map_holder::BucketMapHolder;
|
||||
use solana_sdk::timing::{timestamp, AtomicInterval};
|
||||
use solana_sdk::timing::AtomicInterval;
|
||||
use std::fmt::Debug;
|
||||
use std::sync::atomic::{AtomicBool, AtomicU64, AtomicU8, Ordering};
|
||||
|
||||
@ -38,7 +38,6 @@ pub struct BucketMapHolderStats {
|
||||
pub active_threads: AtomicU64,
|
||||
pub get_range_us: AtomicU64,
|
||||
last_age: AtomicU8,
|
||||
last_age_time: AtomicU64,
|
||||
pub flush_scan_update_us: AtomicU64,
|
||||
pub flush_remove_us: AtomicU64,
|
||||
pub flush_grow_us: AtomicU64,
|
||||
@ -82,12 +81,6 @@ impl BucketMapHolderStats {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_elapsed_ms_and_reset(&self) -> u64 {
|
||||
let now = timestamp();
|
||||
let last = self.last_age_time.swap(now, Ordering::Relaxed);
|
||||
now.saturating_sub(last) // could saturate to 0. That is ok.
|
||||
}
|
||||
|
||||
fn ms_per_age<T: IndexValue>(&self, storage: &BucketMapHolder<T>, elapsed_ms: u64) -> u64 {
|
||||
if !storage.get_startup() {
|
||||
let age_now = storage.current_age();
|
||||
@ -134,11 +127,14 @@ impl BucketMapHolderStats {
|
||||
}
|
||||
|
||||
pub fn report_stats<T: IndexValue>(&self, storage: &BucketMapHolder<T>) {
|
||||
if !self.last_time.should_update(STATS_INTERVAL_MS) {
|
||||
let elapsed_ms = self.last_time.elapsed_ms();
|
||||
if elapsed_ms < STATS_INTERVAL_MS {
|
||||
return;
|
||||
}
|
||||
|
||||
let elapsed_ms = self.get_elapsed_ms_and_reset();
|
||||
if !self.last_time.should_update(STATS_INTERVAL_MS) {
|
||||
return;
|
||||
}
|
||||
|
||||
let ms_per_age = self.ms_per_age(storage, elapsed_ms);
|
||||
|
||||
|
Reference in New Issue
Block a user