From 72251d3346e0622a663e35348abd4ade2b091d1f Mon Sep 17 00:00:00 2001 From: Po Date: Tue, 10 Jun 2025 13:12:22 +0200 Subject: [PATCH] add mgasps metric --- cmd/geth/chaincmd.go | 4 ++++ core/blockchain.go | 2 ++ core/blockchain_insert.go | 1 + 3 files changed, 7 insertions(+) diff --git a/cmd/geth/chaincmd.go b/cmd/geth/chaincmd.go index 69a5ae298c..195ea4b87e 100644 --- a/cmd/geth/chaincmd.go +++ b/cmd/geth/chaincmd.go @@ -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 { diff --git a/core/blockchain.go b/core/blockchain.go index 9208b14487..eec1f33175 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -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") diff --git a/core/blockchain_insert.go b/core/blockchain_insert.go index 695aa6679b..4e3aa0d741 100644 --- a/core/blockchain_insert.go +++ b/core/blockchain_insert.go @@ -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 {