From a544010b03d2aa69a953c957b68837b32fa6a5da Mon Sep 17 00:00:00 2001 From: "Jeff Washington (jwash)" <75863576+jeffwashington@users.noreply.github.com> Date: Wed, 19 May 2021 19:15:35 -0500 Subject: [PATCH] don't log shrink metrics on first call (#17328) * don't log shrink metrics on first call * simplify logic --- runtime/src/accounts_db.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/runtime/src/accounts_db.rs b/runtime/src/accounts_db.rs index 14a54d1947..0be550a69a 100644 --- a/runtime/src/accounts_db.rs +++ b/runtime/src/accounts_db.rs @@ -1057,13 +1057,17 @@ impl ShrinkStats { let last = self.last_report.load(Ordering::Relaxed); let now = solana_sdk::timing::timestamp(); + // last is initialized to 0 by ::default() + // thus, the first 'report' call would always log. + // Instead, the first call now initialializes 'last_report' to now. + let is_first_call = last == 0; let should_report = now.saturating_sub(last) > 1000 && self .last_report .compare_exchange(last, now, Ordering::Relaxed, Ordering::Relaxed) == Ok(last); - if should_report { + if !is_first_call && should_report { datapoint_info!( "shrink_stats", (