mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 05:36:46 +00:00
cmd, core, eth: change the slowblock flag to time duration
This commit is contained in:
parent
df53e28fcd
commit
5e60382c1c
5 changed files with 20 additions and 19 deletions
|
|
@ -667,9 +667,10 @@ var (
|
|||
Usage: "Disables db compaction after import",
|
||||
Category: flags.LoggingCategory,
|
||||
}
|
||||
LogSlowBlockFlag = &cli.Uint64Flag{
|
||||
LogSlowBlockFlag = &cli.DurationFlag{
|
||||
Name: "debug.logslowblock",
|
||||
Usage: "The block execution speed threshold (Mgas/s) below which detailed statistics are logged",
|
||||
Usage: "Block execution time threshold beyond which detailed statistics will be logged (0 means disable)",
|
||||
Value: ethconfig.Defaults.SlowBlockThreshold,
|
||||
Category: flags.LoggingCategory,
|
||||
}
|
||||
|
||||
|
|
@ -1716,7 +1717,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
|
|||
cfg.LogNoHistory = true
|
||||
}
|
||||
if ctx.IsSet(LogSlowBlockFlag.Name) {
|
||||
cfg.SlowBlockThreshold = ctx.Uint64(LogSlowBlockFlag.Name)
|
||||
cfg.SlowBlockThreshold = ctx.Duration(LogSlowBlockFlag.Name)
|
||||
}
|
||||
if ctx.IsSet(LogExportCheckpointsFlag.Name) {
|
||||
cfg.LogExportCheckpoints = ctx.String(LogExportCheckpointsFlag.Name)
|
||||
|
|
@ -2303,7 +2304,7 @@ func MakeChain(ctx *cli.Context, stack *node.Node, readonly bool) (*core.BlockCh
|
|||
StateSizeTracking: ctx.Bool(StateSizeTrackingFlag.Name),
|
||||
|
||||
// Configure the slow block statistic logger
|
||||
SlowBlockThreshold: ctx.Uint64(LogSlowBlockFlag.Name),
|
||||
SlowBlockThreshold: ctx.Duration(LogSlowBlockFlag.Name),
|
||||
}
|
||||
if options.ArchiveMode && !options.Preimages {
|
||||
options.Preimages = true
|
||||
|
|
|
|||
|
|
@ -199,9 +199,9 @@ type BlockChainConfig struct {
|
|||
// StateSizeTracking indicates whether the state size tracking is enabled.
|
||||
StateSizeTracking bool
|
||||
|
||||
// SlowBlockThreshold is the block execution speed threshold (Mgas/s)
|
||||
// below which detailed statistics are logged.
|
||||
SlowBlockThreshold uint64
|
||||
// SlowBlockThreshold is the block execution time threshold beyond which
|
||||
// detailed statistics will be logged.
|
||||
SlowBlockThreshold time.Duration
|
||||
}
|
||||
|
||||
// DefaultConfig returns the default config.
|
||||
|
|
@ -341,8 +341,8 @@ type BlockChain struct {
|
|||
logger *tracing.Hooks
|
||||
stateSizer *state.SizeTracker // State size tracking
|
||||
|
||||
lastForkReadyAlert time.Time // Last time there was a fork readiness print out
|
||||
slowBlockThreshold uint64 // Block execution speed threshold (Mgas/s) below which detailed statistics are logged
|
||||
lastForkReadyAlert time.Time // Last time there was a fork readiness print out
|
||||
slowBlockThreshold time.Duration // Block execution time threshold beyond which detailed statistics will be logged
|
||||
}
|
||||
|
||||
// NewBlockChain returns a fully initialised block chain using information
|
||||
|
|
|
|||
|
|
@ -99,16 +99,16 @@ func (s *ExecuteStats) reportMetrics() {
|
|||
}
|
||||
|
||||
// logSlow prints the detailed execution statistics if the block is regarded as slow.
|
||||
func (s *ExecuteStats) logSlow(block *types.Block, slowBlockThreshold uint64) {
|
||||
if slowBlockThreshold == 0 || s.MgasPerSecond == 0 {
|
||||
func (s *ExecuteStats) logSlow(block *types.Block, slowBlockThreshold time.Duration) {
|
||||
if slowBlockThreshold == 0 {
|
||||
return
|
||||
}
|
||||
if s.MgasPerSecond > float64(slowBlockThreshold) {
|
||||
if s.TotalTime < slowBlockThreshold {
|
||||
return
|
||||
}
|
||||
msg := fmt.Sprintf(`
|
||||
########## SLOW BLOCK #########
|
||||
Block: %v (%#x) txs: %d, mgasps: %.2f
|
||||
Block: %v (%#x) txs: %d, mgasps: %.2f, elapsed: %v
|
||||
|
||||
EVM execution: %v
|
||||
Validation: %v
|
||||
|
|
@ -118,18 +118,17 @@ Account hash: %v
|
|||
Storage hash: %v
|
||||
DB commit: %v
|
||||
Block write: %v
|
||||
Total: %v
|
||||
|
||||
%s
|
||||
##############################
|
||||
`, block.Number(), block.Hash(), len(block.Transactions()), s.MgasPerSecond,
|
||||
`, block.Number(), block.Hash(), len(block.Transactions()), s.MgasPerSecond, common.PrettyDuration(s.TotalTime),
|
||||
common.PrettyDuration(s.Execution), common.PrettyDuration(s.Validation+s.CrossValidation),
|
||||
common.PrettyDuration(s.AccountReads), s.AccountLoaded,
|
||||
common.PrettyDuration(s.StorageReads), s.StorageLoaded,
|
||||
common.PrettyDuration(s.AccountHashes+s.AccountCommits+s.AccountUpdates),
|
||||
common.PrettyDuration(s.StorageCommits+s.StorageUpdates),
|
||||
common.PrettyDuration(s.TrieDBCommit+s.SnapshotCommit), common.PrettyDuration(s.BlockWrite),
|
||||
common.PrettyDuration(s.TotalTime), s.StateReadCacheStats)
|
||||
s.StateReadCacheStats)
|
||||
for _, line := range strings.Split(msg, "\n") {
|
||||
if line == "" {
|
||||
continue
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ var Defaults = Config{
|
|||
RPCTxFeeCap: 1, // 1 ether
|
||||
TxSyncDefaultTimeout: 20 * time.Second,
|
||||
TxSyncMaxTimeout: 1 * time.Minute,
|
||||
SlowBlockThreshold: time.Second * 2,
|
||||
}
|
||||
|
||||
//go:generate go run github.com/fjl/gencodec -type Config -formats toml -out gen_config.go
|
||||
|
|
@ -120,7 +121,7 @@ type Config struct {
|
|||
|
||||
// SlowBlockThreshold is the block execution speed threshold (Mgas/s)
|
||||
// below which detailed statistics are logged.
|
||||
SlowBlockThreshold uint64 `toml:",omitempty"`
|
||||
SlowBlockThreshold time.Duration `toml:",omitempty"`
|
||||
|
||||
// Database options
|
||||
SkipBcVersionCheck bool `toml:"-"`
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ func (c Config) MarshalTOML() (interface{}, error) {
|
|||
StateHistory uint64 `toml:",omitempty"`
|
||||
StateScheme string `toml:",omitempty"`
|
||||
RequiredBlocks map[uint64]common.Hash `toml:"-"`
|
||||
SlowBlockThreshold uint64 `toml:",omitempty"`
|
||||
SlowBlockThreshold time.Duration `toml:",omitempty"`
|
||||
SkipBcVersionCheck bool `toml:"-"`
|
||||
DatabaseHandles int `toml:"-"`
|
||||
DatabaseCache int
|
||||
|
|
@ -137,7 +137,7 @@ func (c *Config) UnmarshalTOML(unmarshal func(interface{}) error) error {
|
|||
StateHistory *uint64 `toml:",omitempty"`
|
||||
StateScheme *string `toml:",omitempty"`
|
||||
RequiredBlocks map[uint64]common.Hash `toml:"-"`
|
||||
SlowBlockThreshold *uint64 `toml:",omitempty"`
|
||||
SlowBlockThreshold *time.Duration `toml:",omitempty"`
|
||||
SkipBcVersionCheck *bool `toml:"-"`
|
||||
DatabaseHandles *int `toml:"-"`
|
||||
DatabaseCache *int
|
||||
|
|
|
|||
Loading…
Reference in a new issue