From e3a17f5a1876ccf3f37910ea2cbb161fc2c685cb Mon Sep 17 00:00:00 2001 From: tuyennhv Date: Tue, 9 Jan 2024 05:00:44 +0700 Subject: [PATCH] feat: track prepare next epoch time (#6256) * feat: track prepare next epoch time * Update packages/beacon-node/src/metrics/metrics/lodestar.ts * Align variable name of timer with histogram naming --------- Co-authored-by: Cayman Co-authored-by: Nico Flaig --- packages/beacon-node/src/chain/prepareNextSlot.ts | 5 +++++ packages/beacon-node/src/metrics/metrics/lodestar.ts | 5 +++++ 2 files changed, 10 insertions(+) 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