From 5cc0f1097b9a3b32967e5cb15b497cdc74f72ed2 Mon Sep 17 00:00:00 2001 From: Michael Sproul Date: Wed, 18 Oct 2023 06:52:50 +0000 Subject: [PATCH] Fix metric for total block production time (#4794) ## Proposed Changes Fix the misplacement of the total block production time metric, which occurred during a previous refactor. Total block production times are no longer skewed low (data from Holesky + blockdreamer): ``` # HELP beacon_block_production_seconds Full runtime of block production # TYPE beacon_block_production_seconds histogram beacon_block_production_seconds_bucket{le="0.005"} 0 beacon_block_production_seconds_bucket{le="0.01"} 0 beacon_block_production_seconds_bucket{le="0.025"} 0 beacon_block_production_seconds_bucket{le="0.05"} 0 beacon_block_production_seconds_bucket{le="0.1"} 0 beacon_block_production_seconds_bucket{le="0.25"} 0 beacon_block_production_seconds_bucket{le="0.5"} 37 beacon_block_production_seconds_bucket{le="1"} 65 beacon_block_production_seconds_bucket{le="2.5"} 66 beacon_block_production_seconds_bucket{le="5"} 66 beacon_block_production_seconds_bucket{le="10"} 66 beacon_block_production_seconds_bucket{le="+Inf"} 66 beacon_block_production_seconds_sum 34.225780452 beacon_block_production_seconds_count 66 ``` ## Additional Info Cheers to @jimmygchen for helping spot this. --- beacon_node/beacon_chain/src/beacon_chain.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/beacon_node/beacon_chain/src/beacon_chain.rs b/beacon_node/beacon_chain/src/beacon_chain.rs index 918d0bd29b7..a45caba79c4 100644 --- a/beacon_node/beacon_chain/src/beacon_chain.rs +++ b/beacon_node/beacon_chain/src/beacon_chain.rs @@ -3978,6 +3978,9 @@ impl BeaconChain { validator_graffiti: Option, verification: ProduceBlockVerification, ) -> Result, BlockProductionError> { + metrics::inc_counter(&metrics::BLOCK_PRODUCTION_REQUESTS); + let _complete_timer = metrics::start_timer(&metrics::BLOCK_PRODUCTION_TIMES); + // Part 1/2 (blocking) // // Load the parent state from disk. @@ -4012,9 +4015,6 @@ impl BeaconChain { self: &Arc, slot: Slot, ) -> Result<(BeaconState, Option), BlockProductionError> { - metrics::inc_counter(&metrics::BLOCK_PRODUCTION_REQUESTS); - let _complete_timer = metrics::start_timer(&metrics::BLOCK_PRODUCTION_TIMES); - let fork_choice_timer = metrics::start_timer(&metrics::BLOCK_PRODUCTION_FORK_CHOICE_TIMES); self.wait_for_fork_choice_before_block_production(slot)?; drop(fork_choice_timer);