From e50a26e6cf917098a683a0087c2362948663e06f Mon Sep 17 00:00:00 2001 From: "Jeff Washington (jwash)" <75863576+jeffwashington@users.noreply.github.com> Date: Mon, 27 Sep 2021 20:22:07 -0500 Subject: [PATCH] AcctIdx: add age_interval_ms() to remove constant use (#20264) --- runtime/src/bucket_map_holder.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/runtime/src/bucket_map_holder.rs b/runtime/src/bucket_map_holder.rs index 19e8a80047..2efd7e359a 100644 --- a/runtime/src/bucket_map_holder.rs +++ b/runtime/src/bucket_map_holder.rs @@ -12,7 +12,7 @@ use std::sync::{Arc, Mutex}; use std::time::Duration; pub type Age = u8; -pub const AGE_MS: u64 = SLOT_MS; // match one age per slot time +const AGE_MS: u64 = SLOT_MS; // match one age per slot time pub struct BucketMapHolder { pub disk: Option>>, @@ -67,7 +67,7 @@ impl BucketMapHolder { fn has_age_interval_elapsed(&self) -> bool { // note that when this returns true, state of age_timer is modified - self.age_timer.should_update(AGE_MS) + self.age_timer.should_update(self.age_interval_ms()) } /// used by bg processes to determine # active threads and how aggressively to flush @@ -153,6 +153,12 @@ impl BucketMapHolder { result } + /// prepare for this to be dynamic if necessary + /// For example, maybe startup has a shorter age interval. + fn age_interval_ms(&self) -> u64 { + AGE_MS + } + // intended to execute in a bg thread pub fn background(&self, exit: Arc, in_mem: Vec>>) { let bins = in_mem.len(); @@ -164,7 +170,8 @@ impl BucketMapHolder { )); } else if self.all_buckets_flushed_at_current_age() { let wait = std::cmp::min( - self.age_timer.remaining_until_next_interval(AGE_MS), + self.age_timer + .remaining_until_next_interval(self.age_interval_ms()), self.stats.remaining_until_next_interval(), );