From a75567bf3b7d36b5dd53ff4f53ed671d622c38b3 Mon Sep 17 00:00:00 2001 From: Manav Darji Date: Thu, 2 Feb 2023 21:03:27 +0530 Subject: [PATCH 1/2] internal/cli: add skiptrace flag --- internal/cli/debug_pprof.go | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/internal/cli/debug_pprof.go b/internal/cli/debug_pprof.go index 01698719e5..a52c95139f 100644 --- a/internal/cli/debug_pprof.go +++ b/internal/cli/debug_pprof.go @@ -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)) From efca13115e3b324379e2acc739574ed1553dc16d Mon Sep 17 00:00:00 2001 From: Manav Darji Date: Thu, 2 Feb 2023 21:03:44 +0530 Subject: [PATCH 2/2] docs: update docs for skiptrace flag --- docs/cli/debug_pprof.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/cli/debug_pprof.md b/docs/cli/debug_pprof.md index 2e7e40b677..78e75f2134 100644 --- a/docs/cli/debug_pprof.md +++ b/docs/cli/debug_pprof.md @@ -6,6 +6,8 @@ The ```debug pprof ``` 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 \ No newline at end of file +- ```output```: Output directory + +- ```skiptrace```: Skip running the trace (default: false) \ No newline at end of file