Skip to content

Commit

Permalink
feat: track epoch transition steps time in metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
twoeths committed Nov 30, 2023
1 parent c39e12a commit 5f6333e
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 1 deletion.
70 changes: 70 additions & 0 deletions packages/beacon-node/src/metrics/metrics/lodestar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,76 @@ export function createLodestarMetrics(
help: "Time to call commit after process a single epoch transition in seconds",
buckets: [0.01, 0.05, 0.1, 0.2, 0.5, 0.75, 1],
}),
epochTransitionJustificationAndFinalizationTime: register.histogram({
name: "lodestar_stfn_epoch_transition_justification_and_finalization_seconds",
help: "Time to process justification and finalization in seconds",
buckets: [0.01, 0.05, 0.1, 0.2, 0.5, 0.75, 1],
}),
epochTransitionInactivityUpdatesTime: register.histogram({
name: "lodestar_stfn_epoch_transition_inactivity_updates_seconds",
help: "Time to process inactivity updates in seconds",
buckets: [0.01, 0.05, 0.1, 0.2, 0.5, 0.75, 1],
}),
epochTransitionRewardsAndPenaltiesTime: register.histogram({
name: "lodestar_stfn_epoch_transition_rewards_and_penalties_seconds",
help: "Time to process rewards and penalties in seconds",
buckets: [0.01, 0.05, 0.1, 0.2, 0.5, 0.75, 1],
}),
epochTransitionRegistryUpdatesTime: register.histogram({
name: "lodestar_stfn_epoch_transition_registry_updates_seconds",
help: "Time to process registry updates in seconds",
buckets: [0.01, 0.05, 0.1, 0.2, 0.5, 0.75, 1],
}),
epochTransitionSlashingsTime: register.histogram({
name: "lodestar_stfn_epoch_transition_slashings_seconds",
help: "Time to process slashings in seconds",
buckets: [0.01, 0.05, 0.1, 0.2, 0.5, 0.75, 1],
}),
epochTransitionEth1DataResetTime: register.histogram({
name: "lodestar_stfn_epoch_transition_eth1_data_reset_seconds",
help: "Time to process eth1 data reset in seconds",
buckets: [0.01, 0.05, 0.1, 0.2, 0.5, 0.75, 1],
}),
epochTransitionEffectiveBalanceUpdatesTime: register.histogram({
name: "lodestar_stfn_epoch_transition_effective_balance_updates_seconds",
help: "Time to process effective balance updates in seconds",
buckets: [0.01, 0.05, 0.1, 0.2, 0.5, 0.75, 1],
}),
epochTransitionSlashingsResetTime: register.histogram({
name: "lodestar_stfn_epoch_transition_slashings_reset_seconds",
help: "Time to process slashings reset in seconds",
buckets: [0.01, 0.05, 0.1, 0.2, 0.5, 0.75, 1],
}),
epochTransitionRandaoMixesResetTime: register.histogram({
name: "lodestar_stfn_epoch_transition_randao_mixes_reset_seconds",
help: "Time to process randao mixes reset in seconds",
buckets: [0.01, 0.05, 0.1, 0.2, 0.5, 0.75, 1],
}),
epochTransitionHistoricalSummariesUpdateTime: register.histogram({
name: "lodestar_stfn_epoch_transition_historical_summaries_update_seconds",
help: "Time to process historical summaries update in seconds",
buckets: [0.01, 0.05, 0.1, 0.2, 0.5, 0.75, 1],
}),
epochTransitionHistoricalRootsUpdateTime: register.histogram({
name: "lodestar_stfn_epoch_transition_historical_roots_update_seconds",
help: "Time to process historical roots update in seconds",
buckets: [0.01, 0.05, 0.1, 0.2, 0.5, 0.75, 1],
}),
epochTransitionParticipationRecordUpdatesTime: register.histogram({
name: "lodestar_stfn_epoch_transition_participation_record_updates_seconds",
help: "Time to process participation record updates in seconds",
buckets: [0.01, 0.05, 0.1, 0.2, 0.5, 0.75, 1],
}),
epochTransitionParticipationFlagUpdatesTime: register.histogram({
name: "lodestar_stfn_epoch_transition_participation_flag_updates_seconds",
help: "Time to process participation flag updates in seconds",
buckets: [0.01, 0.05, 0.1, 0.2, 0.5, 0.75, 1],
}),
epochTransitionSyncCommitteeUpdatesTime: register.histogram({
name: "lodestar_stfn_epoch_transition_sync_committee_updates_seconds",
help: "Time to process sync committee updates in seconds",
buckets: [0.01, 0.05, 0.1, 0.2, 0.5, 0.75, 1],
}),
processBlockTime: register.histogram({
name: "lodestar_stfn_process_block_seconds",
help: "Time to process a single block in seconds",
Expand Down
36 changes: 35 additions & 1 deletion packages/state-transition/src/epoch/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
CachedBeaconStatePhase0,
EpochTransitionCache,
} from "../types.js";
import {BeaconStateTransitionMetrics} from "../metrics.js";
import {processEffectiveBalanceUpdates} from "./processEffectiveBalanceUpdates.js";
import {processEth1DataReset} from "./processEth1DataReset.js";
import {processHistoricalRootsUpdate} from "./processHistoricalRootsUpdate.js";
Expand Down Expand Up @@ -42,29 +43,62 @@ export {

export {computeUnrealizedCheckpoints} from "./computeUnrealizedCheckpoints.js";

export function processEpoch(fork: ForkSeq, state: CachedBeaconStateAllForks, cache: EpochTransitionCache): void {
export function processEpoch(
fork: ForkSeq,
state: CachedBeaconStateAllForks,
cache: EpochTransitionCache,
metrics?: BeaconStateTransitionMetrics | null
): void {
let timer = metrics?.epochTransitionJustificationAndFinalizationTime.startTimer();
processJustificationAndFinalization(state, cache);
timer?.();
if (fork >= ForkSeq.altair) {
timer = metrics?.epochTransitionInactivityUpdatesTime.startTimer();
processInactivityUpdates(state as CachedBeaconStateAltair, cache);
timer?.();
}
timer = metrics?.epochTransitionRewardsAndPenaltiesTime.startTimer();
processRewardsAndPenalties(state, cache);
timer?.();
timer = metrics?.epochTransitionRegistryUpdatesTime.startTimer();
processRegistryUpdates(state, cache);
timer?.();
timer = metrics?.epochTransitionSlashingsTime.startTimer();
processSlashings(state, cache);
timer?.();
timer = metrics?.epochTransitionEth1DataResetTime.startTimer();
processEth1DataReset(state, cache);
timer?.();
timer = metrics?.epochTransitionEffectiveBalanceUpdatesTime.startTimer();
processEffectiveBalanceUpdates(state, cache);
timer?.();
timer = metrics?.epochTransitionSlashingsResetTime.startTimer();
processSlashingsReset(state, cache);
timer?.();
timer = metrics?.epochTransitionRandaoMixesResetTime.startTimer();
processRandaoMixesReset(state, cache);
timer?.();

if (fork >= ForkSeq.capella) {
timer = metrics?.epochTransitionHistoricalSummariesUpdateTime.startTimer();
processHistoricalSummariesUpdate(state as CachedBeaconStateCapella, cache);
timer?.();
} else {
timer = metrics?.epochTransitionHistoricalRootsUpdateTime.startTimer();
processHistoricalRootsUpdate(state, cache);
timer?.();
}

if (fork === ForkSeq.phase0) {
timer = metrics?.epochTransitionParticipationRecordUpdatesTime.startTimer();
processParticipationRecordUpdates(state as CachedBeaconStatePhase0);
timer?.();
} else {
timer = metrics?.epochTransitionParticipationFlagUpdatesTime.startTimer();
processParticipationFlagUpdates(state as CachedBeaconStateAltair);
timer?.();
timer = metrics?.epochTransitionSyncCommitteeUpdatesTime.startTimer();
processSyncCommitteeUpdates(state as CachedBeaconStateAltair);
timer?.();
}
}
14 changes: 14 additions & 0 deletions packages/state-transition/src/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@ import {AttesterStatus} from "./util/attesterStatus.js";
export type BeaconStateTransitionMetrics = {
epochTransitionTime: Histogram;
epochTransitionCommitTime: Histogram;
epochTransitionJustificationAndFinalizationTime: Histogram;
epochTransitionInactivityUpdatesTime: Histogram;
epochTransitionRewardsAndPenaltiesTime: Histogram;
epochTransitionRegistryUpdatesTime: Histogram;
epochTransitionSlashingsTime: Histogram;
epochTransitionEth1DataResetTime: Histogram;
epochTransitionEffectiveBalanceUpdatesTime: Histogram;
epochTransitionSlashingsResetTime: Histogram;
epochTransitionRandaoMixesResetTime: Histogram;
epochTransitionHistoricalSummariesUpdateTime: Histogram;
epochTransitionHistoricalRootsUpdateTime: Histogram;
epochTransitionParticipationRecordUpdatesTime: Histogram;
epochTransitionParticipationFlagUpdatesTime: Histogram;
epochTransitionSyncCommitteeUpdatesTime: Histogram;
processBlockTime: Histogram;
processBlockCommitTime: Histogram;
stateHashTreeRootTime: Histogram;
Expand Down

0 comments on commit 5f6333e

Please sign in to comment.