From 85302d6d1719c41c41ba982aa4fb3814df04c462 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Sun, 21 Nov 2021 21:00:12 +0000 Subject: [PATCH] Add timing metrics to bank creation and rewards calculation (#21066) (#21378) (cherry picked from commit cd6f931223181d5a1d47cba64e857785a175a760) Co-authored-by: sakridge --- runtime/src/bank.rs | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index 9d2f94092a..2805c285ee 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -1246,6 +1246,7 @@ impl Bank { reward_calc_tracer: Option, new_bank_options: NewBankOptions, ) -> Self { + let mut time = Measure::start("bank::new_from_parent"); let NewBankOptions { vote_only_bank, disable_epoch_boundary_optimization, @@ -1345,13 +1346,6 @@ impl Bank { cost_tracker: RwLock::new(CostTracker::default()), }; - datapoint_info!( - "bank-new_from_parent-heights", - ("slot_height", slot, i64), - ("block_height", new.block_height, i64), - ("parent_slot_height", parent.slot(), i64), - ); - let mut ancestors = Vec::with_capacity(1 + new.parents().len()); ancestors.push(new.slot()); new.parents().iter().for_each(|p| { @@ -1418,6 +1412,16 @@ impl Bank { new.update_recent_blockhashes(); } + time.stop(); + + datapoint_info!( + "bank-new_from_parent-heights", + ("slot_height", slot, i64), + ("block_height", new.block_height, i64), + ("parent_slot_height", parent.slot(), i64), + ("time_us", time.as_us(), i64), + ); + new } @@ -1976,6 +1980,7 @@ impl Bank { if prev_epoch == self.epoch() { return; } + let mut timing = Measure::start("epoch_rewards"); // if I'm the first Bank in an epoch, count, claim, disburse rewards from Inflation let slot_in_year = self.slot_in_year_for_inflation(); @@ -2054,6 +2059,7 @@ impl Bank { } else { 0 }; + timing.stop(); datapoint_warn!( "epoch_rewards", @@ -2065,7 +2071,8 @@ impl Bank { ("validator_rewards", validator_rewards_paid, i64), ("active_stake", active_stake, i64), ("pre_capitalization", capitalization, i64), - ("post_capitalization", self.capitalization(), i64) + ("post_capitalization", self.capitalization(), i64), + ("time_us", timing.as_us(), i64) ); }