Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add shuffling indices metrics #12216

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions cl/monitor/shuffling_metrics/shuffling_metrics.go
Original file line number Diff line number Diff line change
@@ -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()))
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}

Expand Down
4 changes: 4 additions & 0 deletions cl/phase1/core/state/cache_accessors.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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)
}

Expand Down
4 changes: 4 additions & 0 deletions cl/phase1/forkchoice/checkpoint_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}

Expand Down
Loading