Skip to content

Commit

Permalink
don't log shrink metrics on first call (#17328)
Browse files Browse the repository at this point in the history
* don't log shrink metrics on first call

* simplify logic
  • Loading branch information
jeffwashington authored May 20, 2021
1 parent 32ec834 commit a544010
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion runtime/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
(
Expand Down

0 comments on commit a544010

Please sign in to comment.