From 9ab7c24e5a6172a0d134ed9f4df5112c39865343 Mon Sep 17 00:00:00 2001 From: Michael Sproul Date: Tue, 29 Mar 2022 16:37:30 +1100 Subject: [PATCH] Add metric for reward cache build time --- beacon_node/operation_pool/src/lib.rs | 2 ++ beacon_node/operation_pool/src/metrics.rs | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/beacon_node/operation_pool/src/lib.rs b/beacon_node/operation_pool/src/lib.rs index 4135f1ae81..dd547017d7 100644 --- a/beacon_node/operation_pool/src/lib.rs +++ b/beacon_node/operation_pool/src/lib.rs @@ -303,9 +303,11 @@ impl OperationPool { .map_err(OpPoolError::GetAttestationsTotalBalanceError)?; // Update the reward cache. + let reward_timer = metrics::start_timer(&metrics::BUILD_REWARD_CACHE_TIME); let mut reward_cache = self.reward_cache.write(); reward_cache.update(state)?; let reward_cache = RwLockWriteGuard::downgrade(reward_cache); + drop(reward_timer); // Split attestations for the previous & current epochs, so that we // can optimise them individually in parallel. diff --git a/beacon_node/operation_pool/src/metrics.rs b/beacon_node/operation_pool/src/metrics.rs index 3fa5208a3d..6fd8567cef 100644 --- a/beacon_node/operation_pool/src/metrics.rs +++ b/beacon_node/operation_pool/src/metrics.rs @@ -3,6 +3,10 @@ use lazy_static::lazy_static; pub use lighthouse_metrics::*; lazy_static! { + pub static ref BUILD_REWARD_CACHE_TIME: Result = try_create_histogram( + "op_pool_build_reward_cache_time", + "Time to build the reward cache before packing attestations" + ); pub static ref ATTESTATION_PREV_EPOCH_PACKING_TIME: Result = try_create_histogram( "op_pool_attestation_prev_epoch_packing_time", "Time to pack previous epoch attestations"