bg threads wait until next expected event (#20126)
This commit is contained in:
committed by
GitHub
parent
3dfbd95ddc
commit
c6d189dac2
@ -159,9 +159,14 @@ impl<T: IndexValue> BucketMapHolder<T> {
|
|||||||
let flush = self.disk.is_some();
|
let flush = self.disk.is_some();
|
||||||
loop {
|
loop {
|
||||||
if self.all_buckets_flushed_at_current_age() {
|
if self.all_buckets_flushed_at_current_age() {
|
||||||
|
let wait = std::cmp::min(
|
||||||
|
self.age_timer.remaining_until_next_interval(AGE_MS),
|
||||||
|
self.stats.remaining_until_next_interval(),
|
||||||
|
);
|
||||||
|
|
||||||
let mut m = Measure::start("wait");
|
let mut m = Measure::start("wait");
|
||||||
self.wait_dirty_or_aged
|
self.wait_dirty_or_aged
|
||||||
.wait_timeout(Duration::from_millis(AGE_MS));
|
.wait_timeout(Duration::from_millis(wait));
|
||||||
m.stop();
|
m.stop();
|
||||||
self.stats
|
self.stats
|
||||||
.bg_waiting_us
|
.bg_waiting_us
|
||||||
|
@ -4,6 +4,9 @@ use solana_sdk::timing::{timestamp, AtomicInterval};
|
|||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use std::sync::atomic::{AtomicU64, AtomicU8, Ordering};
|
use std::sync::atomic::{AtomicU64, AtomicU8, Ordering};
|
||||||
|
|
||||||
|
// stats logged every 10 s
|
||||||
|
const STATS_INTERVAL_MS: u64 = 10_000;
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
pub struct BucketMapHolderStats {
|
pub struct BucketMapHolderStats {
|
||||||
pub get_mem_us: AtomicU64,
|
pub get_mem_us: AtomicU64,
|
||||||
@ -92,9 +95,13 @@ impl BucketMapHolderStats {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn remaining_until_next_interval(&self) -> u64 {
|
||||||
|
self.last_time
|
||||||
|
.remaining_until_next_interval(STATS_INTERVAL_MS)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn report_stats<T: IndexValue>(&self, storage: &BucketMapHolder<T>) {
|
pub fn report_stats<T: IndexValue>(&self, storage: &BucketMapHolder<T>) {
|
||||||
// account index stats every 10 s
|
if !self.last_time.should_update(STATS_INTERVAL_MS) {
|
||||||
if !self.last_time.should_update(10_000) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user