From fc4ba7b2fc27a9c37feb2105e4e6f8f73aedb4c9 Mon Sep 17 00:00:00 2001 From: Tuyen Nguyen Date: Mon, 8 Jan 2024 10:21:40 +0700 Subject: [PATCH] feat: track prepare next epoch time --- 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..5bce756c0d13 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 lodestarPrecomputeEpochTransitionTimer = 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, }); + + lodestarPrecomputeEpochTransitionTimer?.(); } 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..dc96321b3885 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 at lodestar side", + buckets: [1, 2, 3, 4, 8], + }), }, // reprocess attestations