AcctIdx: with multiple bg threads, only log stats once per time interval (#19984)

This commit is contained in:
Jeff Washington (jwash) 2021-09-18 09:55:20 -05:00 committed by GitHub
parent 4e038e94fd
commit 4089f8b06b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -100,7 +100,8 @@ impl<T: IndexValue> AccountsIndexStorage<T> {
wait: Arc<WaitableCondvar>, wait: Arc<WaitableCondvar>,
) { ) {
loop { loop {
wait.wait_timeout(Duration::from_millis(10000)); // account index stats every 10 s // this will transition to waits and thread throttling
wait.wait_timeout(Duration::from_millis(10000));
if exit.load(Ordering::Relaxed) { if exit.load(Ordering::Relaxed) {
break; break;
} }

View File

@ -1,3 +1,4 @@
use solana_sdk::timing::AtomicInterval;
use std::fmt::Debug; use std::fmt::Debug;
use std::sync::atomic::{AtomicU64, Ordering}; use std::sync::atomic::{AtomicU64, Ordering};
@ -19,6 +20,7 @@ pub struct BucketMapHolderStats {
pub count_in_mem: AtomicU64, pub count_in_mem: AtomicU64,
pub per_bucket_count: Vec<AtomicU64>, pub per_bucket_count: Vec<AtomicU64>,
pub get_range_us: AtomicU64, pub get_range_us: AtomicU64,
last_time: AtomicInterval,
} }
impl BucketMapHolderStats { impl BucketMapHolderStats {
@ -46,6 +48,11 @@ impl BucketMapHolderStats {
} }
pub fn report_stats(&self) { pub fn report_stats(&self) {
// account index stats every 10 s
if !self.last_time.should_update(10_000) {
return;
}
let mut ct = 0; let mut ct = 0;
let mut min = usize::MAX; let mut min = usize::MAX;
let mut max = 0; let mut max = 0;