Skip to content

Commit

Permalink
allow FlushStats to accumulate (jito-foundation#215)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffwashington authored and willhickey committed Mar 16, 2024
1 parent 219d777 commit de93586
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions accounts-db/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1721,6 +1721,14 @@ struct FlushStats {
total_size: u64,
}

impl FlushStats {
fn accumulate(&mut self, other: &Self) {
saturating_add_assign!(self.num_flushed, other.num_flushed);
saturating_add_assign!(self.num_purged, other.num_purged);
saturating_add_assign!(self.total_size, other.total_size);
}
}

#[derive(Debug, Default)]
struct LatestAccountsIndexRootsStats {
roots_len: AtomicUsize,
Expand Down Expand Up @@ -6078,9 +6086,7 @@ impl AccountsDb {
if old_slot > max_flushed_root {
if self.should_aggressively_flush_cache() {
if let Some(stats) = self.flush_slot_cache(old_slot) {
flush_stats.num_flushed += stats.num_flushed;
flush_stats.num_purged += stats.num_purged;
flush_stats.total_size += stats.total_size;
flush_stats.accumulate(&stats);
}
}
} else {
Expand Down

0 comments on commit de93586

Please sign in to comment.