mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-18 02:40:45 +00:00
miner: log commit and finalize time for new block (#1904)
This commit is contained in:
parent
be5cfd9756
commit
ca9e69c924
1 changed files with 31 additions and 1 deletions
|
|
@ -42,6 +42,7 @@ import (
|
||||||
"github.com/XinFinOrg/XDPoSChain/ethdb"
|
"github.com/XinFinOrg/XDPoSChain/ethdb"
|
||||||
"github.com/XinFinOrg/XDPoSChain/event"
|
"github.com/XinFinOrg/XDPoSChain/event"
|
||||||
"github.com/XinFinOrg/XDPoSChain/log"
|
"github.com/XinFinOrg/XDPoSChain/log"
|
||||||
|
"github.com/XinFinOrg/XDPoSChain/metrics"
|
||||||
"github.com/XinFinOrg/XDPoSChain/params"
|
"github.com/XinFinOrg/XDPoSChain/params"
|
||||||
"github.com/XinFinOrg/XDPoSChain/trie"
|
"github.com/XinFinOrg/XDPoSChain/trie"
|
||||||
mapset "github.com/deckarep/golang-set/v2"
|
mapset "github.com/deckarep/golang-set/v2"
|
||||||
|
|
@ -62,6 +63,15 @@ const (
|
||||||
txMatchGasLimit = 40000000
|
txMatchGasLimit = 40000000
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
blockNumberGauge = metrics.NewRegisteredGauge("miner/number", nil)
|
||||||
|
normalTxsMeter = metrics.NewRegisteredGauge("miner/txs/normal", nil)
|
||||||
|
specialTxsMeter = metrics.NewRegisteredGauge("miner/txs/special", nil)
|
||||||
|
blockCommitTimer = metrics.NewRegisteredTimer("miner/time/commit", nil)
|
||||||
|
blockFinalizeTimer = metrics.NewRegisteredTimer("miner/time/finalize", nil)
|
||||||
|
blockTotalTimer = metrics.NewRegisteredTimer("miner/time/total", nil)
|
||||||
|
)
|
||||||
|
|
||||||
// Agent can register themself with the worker
|
// Agent can register themself with the worker
|
||||||
type Agent interface {
|
type Agent interface {
|
||||||
Work() chan<- *Work
|
Work() chan<- *Work
|
||||||
|
|
@ -910,6 +920,8 @@ func (w *worker) commitNewWork() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
work.commitTransactions(w.mux, feeCapacity, txs, specialTxs, w.chain, w.coinbase, &w.pendingLogsFeed)
|
work.commitTransactions(w.mux, feeCapacity, txs, specialTxs, w.chain, w.coinbase, &w.pendingLogsFeed)
|
||||||
|
commitEnd := time.Now()
|
||||||
|
|
||||||
// compute uncles for the new block.
|
// compute uncles for the new block.
|
||||||
var (
|
var (
|
||||||
uncles []*types.Header
|
uncles []*types.Header
|
||||||
|
|
@ -922,7 +934,25 @@ func (w *worker) commitNewWork() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if atomic.LoadInt32(&w.mining) == 1 {
|
if atomic.LoadInt32(&w.mining) == 1 {
|
||||||
log.Info("Committing new block", "number", work.Block.Number(), "txs", work.tcount, "special-txs", len(specialTxs), "uncles", len(uncles), "elapsed", common.PrettyDuration(time.Since(tstart)))
|
finalizeEnd := time.Now()
|
||||||
|
commitElapsed := commitEnd.Sub(tstart)
|
||||||
|
finalizeElapsed := finalizeEnd.Sub(commitEnd)
|
||||||
|
totalElapsed := finalizeEnd.Sub(tstart)
|
||||||
|
log.Info("Committing new block",
|
||||||
|
"number", work.Block.Number(),
|
||||||
|
"txs", work.tcount,
|
||||||
|
"special_txs", len(specialTxs),
|
||||||
|
"uncles", len(uncles),
|
||||||
|
"commit_time", common.PrettyDuration(commitElapsed),
|
||||||
|
"finalize_time", common.PrettyDuration(finalizeElapsed),
|
||||||
|
"total_time", common.PrettyDuration(totalElapsed),
|
||||||
|
)
|
||||||
|
blockNumberGauge.Update(work.Block.Number().Int64())
|
||||||
|
normalTxsMeter.Update(int64(work.tcount))
|
||||||
|
specialTxsMeter.Update(int64(len(specialTxs)))
|
||||||
|
blockCommitTimer.Update(commitElapsed)
|
||||||
|
blockFinalizeTimer.Update(finalizeElapsed)
|
||||||
|
blockTotalTimer.Update(totalElapsed)
|
||||||
w.unconfirmed.Shift(work.Block.NumberU64() - 1)
|
w.unconfirmed.Shift(work.Block.NumberU64() - 1)
|
||||||
w.lastParentBlockCommit = parent.Hash().Hex()
|
w.lastParentBlockCommit = parent.Hash().Hex()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue