diff --git a/packages/beacon-node/src/chain/prepareNextSlot.ts b/packages/beacon-node/src/chain/prepareNextSlot.ts index e2bffd5bc8c6..60658b69ca98 100644 --- a/packages/beacon-node/src/chain/prepareNextSlot.ts +++ b/packages/beacon-node/src/chain/prepareNextSlot.ts @@ -97,6 +97,9 @@ export class PrepareNextSlotScheduler { headRoot, isEpochTransition, }); + const precomputeEpochTransitionTimer = isEpochTransition + ? this.metrics?.precomputeNextEpochTransition.duration.startTimer() + : null; // No need to wait for this or the clock drift // Pre Bellatrix: we only do precompute state transition for the last slot of epoch // For Bellatrix, we always do the `processSlots()` to prepare payload for the next slot @@ -133,6 +136,8 @@ export class PrepareNextSlotScheduler { prepareSlot, previousHits, }); + + precomputeEpochTransitionTimer?.(); } if (isExecutionStateType(prepareState)) { diff --git a/packages/beacon-node/src/metrics/metrics/lodestar.ts b/packages/beacon-node/src/metrics/metrics/lodestar.ts index ea2251b3dce5..f6b143913346 100644 --- a/packages/beacon-node/src/metrics/metrics/lodestar.ts +++ b/packages/beacon-node/src/metrics/metrics/lodestar.ts @@ -1298,6 +1298,11 @@ export function createLodestarMetrics( name: "lodestar_precompute_next_epoch_transition_waste_total", help: "Total number of precomputing next epoch transition wasted", }), + duration: register.histogram({ + name: "lodestar_precompute_next_epoch_transition_duration_seconds", + help: "Duration of precomputeNextEpochTransition, including epoch transition and hashTreeRoot", + buckets: [1, 2, 3, 4, 8], + }), }, // reprocess attestations