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)
|
- ```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
|
- ```output```: Output directory
|
||||||
|
|
||||||
|
- ```skiptrace```: Skip running the trace (default: false)
|
||||||
|
|
@ -18,6 +18,7 @@ type DebugPprofCommand struct {
|
||||||
|
|
||||||
seconds uint64
|
seconds uint64
|
||||||
output string
|
output string
|
||||||
|
skiptrace bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *DebugPprofCommand) MarkDown() string {
|
func (p *DebugPprofCommand) MarkDown() string {
|
||||||
|
|
@ -44,7 +45,7 @@ func (d *DebugPprofCommand) Flags() *flagset.Flagset {
|
||||||
|
|
||||||
flags.Uint64Flag(&flagset.Uint64Flag{
|
flags.Uint64Flag(&flagset.Uint64Flag{
|
||||||
Name: "seconds",
|
Name: "seconds",
|
||||||
Usage: "seconds to trace",
|
Usage: "seconds to profile",
|
||||||
Value: &d.seconds,
|
Value: &d.seconds,
|
||||||
Default: 2,
|
Default: 2,
|
||||||
})
|
})
|
||||||
|
|
@ -54,6 +55,15 @@ func (d *DebugPprofCommand) Flags() *flagset.Flagset {
|
||||||
Usage: "Output directory",
|
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
|
return flags
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -119,11 +129,16 @@ func (d *DebugPprofCommand) Run(args []string) int {
|
||||||
ctx, cancelFn := context.WithCancel(context.Background())
|
ctx, cancelFn := context.WithCancel(context.Background())
|
||||||
trapSignal(cancelFn)
|
trapSignal(cancelFn)
|
||||||
|
|
||||||
|
// Only take cpu and heap profiles by default
|
||||||
profiles := map[string]string{
|
profiles := map[string]string{
|
||||||
"heap": "heap",
|
"heap": "heap",
|
||||||
"cpu": "cpu",
|
"cpu": "cpu",
|
||||||
"trace": "trace",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !d.skiptrace {
|
||||||
|
profiles["trace"] = "trace"
|
||||||
|
}
|
||||||
|
|
||||||
for profile, filename := range profiles {
|
for profile, filename := range profiles {
|
||||||
if err := pprofProfile(ctx, profile, filename); err != nil {
|
if err := pprofProfile(ctx, profile, filename); err != nil {
|
||||||
d.UI.Error(fmt.Sprintf("Error creating profile '%s': %v", profile, err))
|
d.UI.Error(fmt.Sprintf("Error creating profile '%s': %v", profile, err))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue