mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 22:56:43 +00:00
internal/cli: add skiptrace flag for profiling (#715)
* internal/cli: add skiptrace flag * docs: update docs for skiptrace flag
This commit is contained in:
parent
d6899d79ea
commit
a1871ad22c
2 changed files with 25 additions and 8 deletions
|
|
@ -6,6 +6,8 @@ The ```debug pprof <enode>``` command will create an archive containing bor ppro
|
|||
|
||||
- ```address```: Address of the grpc endpoint (default: 127.0.0.1:3131)
|
||||
|
||||
- ```seconds```: seconds to trace (default: 2)
|
||||
- ```seconds```: seconds to profile (default: 2)
|
||||
|
||||
- ```output```: Output directory
|
||||
|
||||
- ```skiptrace```: Skip running the trace (default: false)
|
||||
|
|
@ -16,8 +16,9 @@ import (
|
|||
type DebugPprofCommand struct {
|
||||
*Meta2
|
||||
|
||||
seconds uint64
|
||||
output string
|
||||
seconds uint64
|
||||
output string
|
||||
skiptrace bool
|
||||
}
|
||||
|
||||
func (p *DebugPprofCommand) MarkDown() string {
|
||||
|
|
@ -44,7 +45,7 @@ func (d *DebugPprofCommand) Flags() *flagset.Flagset {
|
|||
|
||||
flags.Uint64Flag(&flagset.Uint64Flag{
|
||||
Name: "seconds",
|
||||
Usage: "seconds to trace",
|
||||
Usage: "seconds to profile",
|
||||
Value: &d.seconds,
|
||||
Default: 2,
|
||||
})
|
||||
|
|
@ -54,6 +55,15 @@ func (d *DebugPprofCommand) Flags() *flagset.Flagset {
|
|||
Usage: "Output directory",
|
||||
})
|
||||
|
||||
// Trace profiles can be expensive and take too much size (for grpc).
|
||||
// This flag will help in making it optional.
|
||||
flags.BoolFlag(&flagset.BoolFlag{
|
||||
Name: "skiptrace",
|
||||
Value: &d.skiptrace,
|
||||
Usage: "Skip running the trace",
|
||||
Default: false,
|
||||
})
|
||||
|
||||
return flags
|
||||
}
|
||||
|
||||
|
|
@ -119,11 +129,16 @@ func (d *DebugPprofCommand) Run(args []string) int {
|
|||
ctx, cancelFn := context.WithCancel(context.Background())
|
||||
trapSignal(cancelFn)
|
||||
|
||||
// Only take cpu and heap profiles by default
|
||||
profiles := map[string]string{
|
||||
"heap": "heap",
|
||||
"cpu": "cpu",
|
||||
"trace": "trace",
|
||||
"heap": "heap",
|
||||
"cpu": "cpu",
|
||||
}
|
||||
|
||||
if !d.skiptrace {
|
||||
profiles["trace"] = "trace"
|
||||
}
|
||||
|
||||
for profile, filename := range profiles {
|
||||
if err := pprofProfile(ctx, profile, filename); err != nil {
|
||||
d.UI.Error(fmt.Sprintf("Error creating profile '%s': %v", profile, err))
|
||||
|
|
|
|||
Loading…
Reference in a new issue