From fa71d42fa4722acbb6af4dfdd90925f3f873e71d Mon Sep 17 00:00:00 2001 From: "Jeff Washington (jwash)" <75863576+jeffwashington@users.noreply.github.com> Date: Wed, 30 Jun 2021 19:46:59 -0500 Subject: [PATCH] report on min/max bin stats for accounts index (#18338) (cherry picked from commit 531f1bce78116489424478b00a9f96352cae366b) --- runtime/src/accounts_db.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/runtime/src/accounts_db.rs b/runtime/src/accounts_db.rs index 9990eb8f289ad1..f848b150b0467d 100644 --- a/runtime/src/accounts_db.rs +++ b/runtime/src/accounts_db.rs @@ -166,6 +166,9 @@ struct GenerateIndexTimings { pub index_time: u64, pub scan_time: u64, pub insertion_time_us: u64, + pub min_bin_size: usize, + pub max_bin_size: usize, + pub total_items: usize, } impl GenerateIndexTimings { @@ -176,6 +179,9 @@ impl GenerateIndexTimings { ("total_us", self.index_time, i64), ("scan_stores_us", self.scan_time, i64), ("insertion_time_us", self.insertion_time_us, i64), + ("min_bin_size", self.min_bin_size as i64, i64), + ("max_bin_size", self.max_bin_size as i64, i64), + ("total_items", self.total_items as i64, i64), ); } } @@ -5945,10 +5951,28 @@ impl AccountsDb { }) .sum(); index_time.stop(); + + let mut min_bin_size = usize::MAX; + let mut max_bin_size = usize::MIN; + let total_items = self + .accounts_index + .account_maps + .iter() + .map(|i| { + let len = i.read().unwrap().len(); + min_bin_size = std::cmp::min(min_bin_size, len); + max_bin_size = std::cmp::max(max_bin_size, len); + len + }) + .sum(); + let timings = GenerateIndexTimings { scan_time, index_time: index_time.as_us(), insertion_time_us: insertion_time_us.load(Ordering::Relaxed), + min_bin_size, + max_bin_size, + total_items, }; timings.report();