add mgasps metric

This commit is contained in:
Po 2025-06-10 13:12:22 +02:00
parent 72a7e9ea5a
commit 72251d3346
3 changed files with 7 additions and 0 deletions

View file

@ -440,6 +440,7 @@ func showMetrics() {
blockWriteTimer := metrics.GetOrRegisterResettingTimer("chain/write", nil)
blockPrefetchExecuteTimer := metrics.GetOrRegisterResettingTimer("chain/prefetch/executes", nil)
mgaspsHist := metrics.GetOrRegisterHistogram("chain/execution/mgasps", nil, metrics.NewUniformSample(2000))
// not important
fmt.Println("accountReadSingleTimer", accountReadSingleTimer.Total())
@ -478,6 +479,9 @@ func showMetrics() {
// total
fmt.Println("blockInsertTimer", blockInsertTimer.Total())
mgasps := mgaspsHist.Snapshot()
fmt.Println("mgasps,mean,max,min:", mgasps.Mean(), mgasps.Max(), mgasps.Min())
}
func exportChain(ctx *cli.Context) error {

View file

@ -98,6 +98,8 @@ var (
blockPrefetchTxsInvalidMeter = metrics.NewRegisteredMeter("chain/prefetch/txs/invalid", nil)
blockPrefetchTxsValidMeter = metrics.NewRegisteredMeter("chain/prefetch/txs/valid", nil)
mgaspsHist = metrics.NewRegisteredHistogram("chain/execution/mgasps", nil, metrics.NewUniformSample(2000))
errInsertionInterrupted = errors.New("insertion is interrupted")
errChainStopped = errors.New("blockchain is stopped")
errInvalidOldChain = errors.New("invalid old chain")

View file

@ -48,6 +48,7 @@ func (st *insertStats) report(chain []*types.Block, index int, snapDiffItems, sn
)
// Update the Mgas per second gauge
chainMgaspsGauge.Update(int64(mgasps))
mgaspsHist.Update(int64(mgasps))
// If we're at the last block of the batch or report period reached, log
if index == len(chain)-1 || elapsed >= statsReportLimit {