diff --git a/cl/monitor/shuffling_metrics/shuffling_metrics.go b/cl/monitor/shuffling_metrics/shuffling_metrics.go new file mode 100644 index 00000000000..cfc5b74219b --- /dev/null +++ b/cl/monitor/shuffling_metrics/shuffling_metrics.go @@ -0,0 +1,17 @@ +package shuffling_metrics + +import ( + "time" + + "github.com/erigontech/erigon-lib/metrics" +) + +var ( + // shuffling metrics + computeShuffledIndicies = metrics.GetOrCreateGauge("compute_shuffled_indices") +) + +// ObserveComputeShuffledIndiciesTime sets computeShuffledIndicies time +func ObserveComputeShuffledIndiciesTime(startTime time.Time) { + computeShuffledIndicies.Set(float64(time.Since(startTime).Microseconds())) +} diff --git a/cl/persistence/state/historical_states_reader/attesting_indicies.go b/cl/persistence/state/historical_states_reader/attesting_indicies.go index 4ac8ded610a..e38f556d4f5 100644 --- a/cl/persistence/state/historical_states_reader/attesting_indicies.go +++ b/cl/persistence/state/historical_states_reader/attesting_indicies.go @@ -19,11 +19,13 @@ package historical_states_reader import ( "errors" "fmt" + "time" libcommon "github.com/erigontech/erigon-lib/common" "github.com/erigontech/erigon-lib/kv" "github.com/erigontech/erigon/cl/clparams" "github.com/erigontech/erigon/cl/cltypes/solid" + "github.com/erigontech/erigon/cl/monitor/shuffling_metrics" "github.com/erigontech/erigon/cl/persistence/base_encoding" state_accessors "github.com/erigontech/erigon/cl/persistence/state" "github.com/erigontech/erigon/cl/phase1/core/state/shuffling" @@ -76,7 +78,9 @@ func (r *HistoricalStatesReader) ComputeCommittee(mix libcommon.Hash, indicies [ shuffledIndicies = shuffledIndicesInterface } else { shuffledIndicies = make([]uint64, lenIndicies) + start := time.Now() shuffledIndicies = shuffling.ComputeShuffledIndicies(cfg, mix, shuffledIndicies, indicies, slot) + shuffling_metrics.ObserveComputeShuffledIndiciesTime(start) r.shuffledSetsCache.Add(epoch, shuffledIndicies) } diff --git a/cl/phase1/core/state/cache_accessors.go b/cl/phase1/core/state/cache_accessors.go index c152954292d..6550190e2b0 100644 --- a/cl/phase1/core/state/cache_accessors.go +++ b/cl/phase1/core/state/cache_accessors.go @@ -22,8 +22,10 @@ import ( "errors" "fmt" "math" + "time" "github.com/erigontech/erigon/cl/cltypes/solid" + "github.com/erigontech/erigon/cl/monitor/shuffling_metrics" "github.com/erigontech/erigon/cl/phase1/core/state/shuffling" shuffling2 "github.com/erigontech/erigon/cl/phase1/core/state/shuffling" @@ -87,7 +89,9 @@ func (b *CachingBeaconState) ComputeCommittee( shuffledIndicies = shuffledIndicesInterface } else { shuffledIndicies = make([]uint64, lenIndicies) + start := time.Now() shuffledIndicies = shuffling.ComputeShuffledIndicies(b.BeaconConfig(), mix, shuffledIndicies, indicies, slot) + shuffling_metrics.ObserveComputeShuffledIndiciesTime(start) b.shuffledSetsCache.Add(seed, shuffledIndicies) } diff --git a/cl/phase1/forkchoice/checkpoint_state.go b/cl/phase1/forkchoice/checkpoint_state.go index 3c56027875e..3dd9b86a73c 100644 --- a/cl/phase1/forkchoice/checkpoint_state.go +++ b/cl/phase1/forkchoice/checkpoint_state.go @@ -19,9 +19,11 @@ package forkchoice import ( "errors" "fmt" + "time" "github.com/erigontech/erigon/cl/cltypes/solid" "github.com/erigontech/erigon/cl/monitor" + "github.com/erigontech/erigon/cl/monitor/shuffling_metrics" "github.com/erigontech/erigon/cl/phase1/core/state/shuffling" "github.com/Giulio2002/bls" @@ -114,7 +116,9 @@ func newCheckpointState(beaconConfig *clparams.BeaconChainConfig, anchorPublicKe activeIndicies := c.getActiveIndicies(epoch) monitor.ObserveActiveValidatorsCount(len(activeIndicies)) c.shuffledSet = make([]uint64, len(activeIndicies)) + start := time.Now() c.shuffledSet = shuffling.ComputeShuffledIndicies(c.beaconConfig, c.randaoMixes.Get(int(mixPosition)), c.shuffledSet, activeIndicies, epoch*beaconConfig.SlotsPerEpoch) + shuffling_metrics.ObserveComputeShuffledIndiciesTime(start) return c }