From cef9e0de0c9d0e39dffab9d633098df3f16b3dd8 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Mon, 21 Jun 2021 10:12:27 -0500 Subject: [PATCH] generate_index timings (#17983) (#18049) (cherry picked from commit 1feaaf009d8f11303c1a8f73cf963be5ffedb420) Co-authored-by: Jeff Washington (jwash) <75863576+jeffwashington@users.noreply.github.com> --- runtime/src/accounts_db.rs | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/runtime/src/accounts_db.rs b/runtime/src/accounts_db.rs index 84b0ce7959..a6497338b9 100644 --- a/runtime/src/accounts_db.rs +++ b/runtime/src/accounts_db.rs @@ -161,6 +161,23 @@ pub struct ErrorCounters { pub not_allowed_during_cluster_maintenance: usize, } +#[derive(Default, Debug)] +struct GenerateIndexTimings { + pub index_time: u64, + pub scan_time: u64, +} + +impl GenerateIndexTimings { + pub fn report(&self) { + datapoint_info!( + "generate_index", + // we cannot accurately measure index insertion time because of many threads and lock contention + ("total_us", self.index_time, i64), + ("scan_stores_us", self.scan_time, i64), + ); + } +} + #[derive(Default, Debug, PartialEq, Clone)] pub struct AccountInfo { /// index identifying the append storage @@ -5846,13 +5863,11 @@ impl AccountsDb { }) .sum(); index_time.stop(); - - datapoint_info!( - "generate_index", - // we cannot accurately measure index insertion time because of many threads and lock contention - ("total_us", index_time.as_us(), i64), - ("scan_stores_us", scan_time, i64), - ); + let timings = GenerateIndexTimings { + scan_time, + index_time: index_time.as_us(), + }; + timings.report(); // Need to add these last, otherwise older updates will be cleaned for slot in slots {