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