Skip to content

Commit

Permalink
add metrics for epoch processing subprocesses (#12151)
Browse files Browse the repository at this point in the history
Co-authored-by: shota.silagadze <shota.silagadze@taal.com>
  • Loading branch information
shotasilagadze and shotasilagadzetaal authored Oct 1, 2024
1 parent 5777e84 commit 43dcfba
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 6 deletions.
56 changes: 55 additions & 1 deletion cl/monitor/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,16 @@ var (
batchVerificationThroughput = metrics.GetOrCreateGauge("aggregation_per_signature")

// Epoch processing metrics
epochProcessingTime = metrics.GetOrCreateGauge("epoch_processing_time")
epochProcessingTime = metrics.GetOrCreateGauge("epoch_processing_time")
processJustificationBitsAndFinalityTime = metrics.GetOrCreateGauge("process_justification_bits_and_finality_time")
ProcessInactivityScoresTime = metrics.GetOrCreateGauge("process_inactivity_ccores_time")
processRewardsAndPenaltiesTime = metrics.GetOrCreateGauge("process_rewards_and_penalties_time")
processRegistryUpdatesTime = metrics.GetOrCreateGauge("process_registry_updates_time")
processSlashingsTime = metrics.GetOrCreateGauge("process_slashings_time")
processEffectiveBalanceUpdatesTime = metrics.GetOrCreateGauge("process_effective_balance_updates_time")
processHistoricalRootsUpdateTime = metrics.GetOrCreateGauge("process_historical_roots_update_time")
processParticipationFlagUpdatesTime = metrics.GetOrCreateGauge("process_participation_flag_updates_time")
processSyncCommitteeUpdateTime = metrics.GetOrCreateGauge("process_sync_committee_update_time")

// Network metrics
gossipTopicsMetricCounterPrefix = "gossip_topics_seen"
Expand Down Expand Up @@ -62,6 +71,51 @@ func ObserveEpochProcessingTime(startTime time.Time) {
epochProcessingTime.Set(float64(time.Since(startTime).Microseconds()))
}

// ObserveProcessJustificationBitsAndFinalityTime sets ProcessJustificationBitsAndFinality time
func ObserveProcessJustificationBitsAndFinalityTime(startTime time.Time) {
processJustificationBitsAndFinalityTime.Set(float64(time.Since(startTime).Microseconds()))
}

// ObserveProcessRewardsAndPenaltiesTime sets ProcessRewardsAndPenalties time
func ObserveProcessRewardsAndPenaltiesTime(startTime time.Time) {
processRewardsAndPenaltiesTime.Set(float64(time.Since(startTime).Microseconds()))
}

// ObserveProcessParticipationFlagUpdatesTime sets ProcessParticipationFlagUpdates time
func ObserveProcessParticipationFlagUpdatesTime(startTime time.Time) {
processParticipationFlagUpdatesTime.Set(float64(time.Since(startTime).Microseconds()))
}

// ObserveProcessInactivityScoresTime sets ProcessJustificationBitsAndFinality time
func ObserveProcessInactivityScoresTime(startTime time.Time) {
ProcessInactivityScoresTime.Set(float64(time.Since(startTime).Microseconds()))
}

// ObserveProcessHistoricalRootsUpdateTime sets ProcessHistoricalRootsUpdate time
func ObserveProcessHistoricalRootsUpdateTime(startTime time.Time) {
processHistoricalRootsUpdateTime.Set(float64(time.Since(startTime).Microseconds()))
}

// ObserveProcessSyncCommitteeUpdateTime sets ProcessSyncCommitteeUpdate time
func ObserveProcessSyncCommitteeUpdateTime(startTime time.Time) {
processSyncCommitteeUpdateTime.Set(float64(time.Since(startTime).Microseconds()))
}

// ObserveProcessEffectiveBalanceUpdatesTime sets ProcessEffectiveBalanceUpdates time
func ObserveProcessEffectiveBalanceUpdatesTime(startTime time.Time) {
processEffectiveBalanceUpdatesTime.Set(float64(time.Since(startTime).Microseconds()))
}

// ObserveProcessRegistryUpdatesTime sets ProcessRegistryUpdates time
func ObserveProcessRegistryUpdatesTime(startTime time.Time) {
processRegistryUpdatesTime.Set(float64(time.Since(startTime).Microseconds()))
}

// ObserveProcessSlashingsTime sets ProcessSlashings time
func ObserveProcessSlashingsTime(startTime time.Time) {
processSlashingsTime.Set(float64(time.Since(startTime).Microseconds()))
}

// ObserveAttestHit increments the attestation hit metric
func ObserveAttestationBlockProcessingTime(startTime time.Time) {
attestationBlockProcessingTime.Set(microToMilli(time.Since(startTime).Microseconds()))
Expand Down
34 changes: 29 additions & 5 deletions cl/transition/impl/eth2/statechange/process_epoch.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@
package statechange

import (
"time"

"github.com/erigontech/erigon/cl/abstract"
"github.com/erigontech/erigon/cl/clparams"
"github.com/erigontech/erigon/cl/cltypes/solid"
"github.com/erigontech/erigon/cl/monitor"
"github.com/erigontech/erigon/cl/phase1/core/state"
)

Expand All @@ -42,60 +45,81 @@ func GetUnslashedIndiciesSet(cfg *clparams.BeaconChainConfig, previousEpoch uint
// ProcessEpoch process epoch transition.
func ProcessEpoch(s abstract.BeaconState) error {
eligibleValidators := state.EligibleValidatorsIndicies(s)
// start := time.Now()
var unslashedIndiciesSet [][]bool
if s.Version() >= clparams.AltairVersion {
unslashedIndiciesSet = GetUnslashedIndiciesSet(s.BeaconConfig(), state.PreviousEpoch(s), s.ValidatorSet(), s.PreviousEpochParticipation())
}
start := time.Now()
if err := ProcessJustificationBitsAndFinality(s, unslashedIndiciesSet); err != nil {
return err
}
monitor.ObserveProcessJustificationBitsAndFinalityTime(start)
// fmt.Println("ProcessJustificationBitsAndFinality", time.Since(start))
// start = time.Now()

if s.Version() >= clparams.AltairVersion {
start = time.Now()
if err := ProcessInactivityScores(s, eligibleValidators, unslashedIndiciesSet); err != nil {
return err
}
monitor.ObserveProcessInactivityScoresTime(start)
}

// fmt.Println("ProcessInactivityScores", time.Since(start))
// start = time.Now()
start = time.Now()
if err := ProcessRewardsAndPenalties(s, eligibleValidators, unslashedIndiciesSet); err != nil {
return err
}
monitor.ObserveProcessRewardsAndPenaltiesTime(start)

// fmt.Println("ProcessRewardsAndPenalties", time.Since(start))
// start = time.Now()
start = time.Now()
if err := ProcessRegistryUpdates(s); err != nil {
return err
}
monitor.ObserveProcessRegistryUpdatesTime(start)

// fmt.Println("ProcessRegistryUpdates", time.Since(start))
// start = time.Now()
start = time.Now()
if err := ProcessSlashings(s); err != nil {
return err
}
monitor.ObserveProcessSlashingsTime(start)

// fmt.Println("ProcessSlashings", time.Since(start))
ProcessEth1DataReset(s)
// start = time.Now()
start = time.Now()
if err := ProcessEffectiveBalanceUpdates(s); err != nil {
return err
}
monitor.ObserveProcessEffectiveBalanceUpdatesTime(start)

// fmt.Println("ProcessEffectiveBalanceUpdates", time.Since(start))
ProcessSlashingsReset(s)
ProcessRandaoMixesReset(s)

start = time.Now()
if err := ProcessHistoricalRootsUpdate(s); err != nil {
return err
}
monitor.ObserveProcessHistoricalRootsUpdateTime(start)

if s.Version() == clparams.Phase0Version {
if err := ProcessParticipationRecordUpdates(s); err != nil {
return err
}
}

if s.Version() >= clparams.AltairVersion {
start = time.Now()
ProcessParticipationFlagUpdates(s)
monitor.ObserveProcessParticipationFlagUpdatesTime(start)

start = time.Now()
if err := ProcessSyncCommitteeUpdate(s); err != nil {
return err
}
monitor.ObserveProcessSyncCommitteeUpdateTime(start)
}
return nil
}

0 comments on commit 43dcfba

Please sign in to comment.