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 metrics for parallel processor #254

Merged
Merged
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
40 changes: 39 additions & 1 deletion core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,18 @@ var (
txDAGGenerateTimer = metrics.NewRegisteredTimer("chain/block/txdag/gen", nil)
txDAGReaderChanGauge = metrics.NewRegisteredGauge("chain/block/txdag/reader/chan", nil)

// expensive metrics
// metrics of reasons why a block is processed in a parallel EVM or serial EVM
parallelConditionTooDeep = metrics.NewRegisteredMeter("chain/parallel/condition/toodeep", nil)
parallelConditionTxDAGMiss = metrics.NewRegisteredMeter("chain/parallel/condition/txdagmiss", nil)
parallelConditionByzantium = metrics.NewRegisteredMeter("chain/parallel/condition/byzantium", nil)

// metrics to identify whether a block is processed in parallel EVM or serial EVM
parallelInSequencial = metrics.NewRegisteredMeter("chain/parallel/sequencial", nil)
parallelTxDepth = metrics.NewRegisteredMeter("chain/parallel/txdepth", nil)
// TxDepthRatio = TxDepth / TxNum * 100
parallelTxDepthRatio = metrics.NewRegisteredGauge("chain/parallel/txdepth/ratio", nil)

parallelTxNumMeter = metrics.NewRegisteredMeter("chain/parallel/txs", nil)
parallelEnableMeter = metrics.NewRegisteredMeter("chain/parallel/enable", nil)
parallelFallbackMeter = metrics.NewRegisteredMeter("chain/parallel/fallback", nil)
Expand Down Expand Up @@ -1765,11 +1777,36 @@ func (bc *BlockChain) useSerialProcessor(block *types.Block) (bool, bool) {
// if the dependencies are too deep, we will fallback to serial processing
txCount := len(block.Transactions())
_, depth := BuildTxLevels(txCount, bc.vmConfig.TxDAG)
tooDeep := float64(depth)/float64(txCount) > bc.vmConfig.TxDAGMaxDepthRatio
var depthRatio float64

if txCount > 0 {
depthRatio = float64(depth) / float64(txCount)
} else {
depthRatio = 0
}
tooDeep := depthRatio > bc.vmConfig.TxDAGMaxDepthRatio
isByzantium := bc.chainConfig.IsByzantium(block.Number())

txDAGMissButNecessary := bc.vmConfig.TxDAG == nil && (bc.vmConfig.EnableParallelUnorderedMerge || bc.vmConfig.EnableTxParallelMerge)
useSerialProcessor := !bc.vmConfig.EnableParallelExec || txDAGMissButNecessary || tooDeep || !isByzantium

// mark the metrics
defer func() {
parallelTxDepth.Mark(int64(depth))
parallelTxDepthRatio.Update(int64(depthRatio * 100))
// put reasons in expensive metrics
if metrics.EnabledExpensive {
if tooDeep {
parallelConditionTooDeep.Mark(1)
}
if bc.vmConfig.TxDAG == nil {
parallelConditionTxDAGMiss.Mark(1)
}
if isByzantium {
parallelConditionByzantium.Mark(1)
}
}
}()
return useSerialProcessor, tooDeep
}

Expand Down Expand Up @@ -2036,6 +2073,7 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool) (int, error)
// Process block using the parent state as reference point
pstart = time.Now()
if useSerialProcessor {
parallelInSequencial.Mark(1)
receipts, logs, usedGas, err = bc.serialProcessor.Process(block, statedb, bc.vmConfig)
blockProcessedInParallel = false
} else {
Expand Down
Loading