From 5bd73fc218441f8416795d214ed3969ac23100ae Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Tue, 15 Feb 2022 14:10:07 -0500 Subject: [PATCH] debug: limit the size of the trace We've noticed that a trace that is captured over the full duration is too large to open on most machines. A trace.out captured over just the interval period (30s by default) should be a more than enough time to capture trace data. --- .changelog/12359.txt | 3 +++ command/debug/debug.go | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 .changelog/12359.txt diff --git a/.changelog/12359.txt b/.changelog/12359.txt new file mode 100644 index 000000000..6c6c3e451 --- /dev/null +++ b/.changelog/12359.txt @@ -0,0 +1,3 @@ +```release-note:improvement +debug: reduce the capture time for trace to only a single interval instead of the full duration to make trace.out easier to open without running into OOM errors. +``` diff --git a/command/debug/debug.go b/command/debug/debug.go index 1749d76b2..acbe36d93 100644 --- a/command/debug/debug.go +++ b/command/debug/debug.go @@ -413,7 +413,7 @@ func (c *cmd) captureLongRunning(ctx context.Context) error { g.Go(func() error { // use ctx without a timeout to allow the trace to finish sending - return c.captureTrace(ctx, s) + return c.captureTrace(ctx, int(c.interval.Seconds())) }) } if c.captureTarget(targetLogs) { @@ -443,8 +443,8 @@ func (c *cmd) captureGoRoutines(outputDir string) error { return ioutil.WriteFile(filepath.Join(outputDir, "goroutine.prof"), gr, 0644) } -func (c *cmd) captureTrace(ctx context.Context, s float64) error { - prof, err := c.client.Debug().PProf(ctx, "trace", int(s)) +func (c *cmd) captureTrace(ctx context.Context, duration int) error { + prof, err := c.client.Debug().PProf(ctx, "trace", duration) if err != nil { return fmt.Errorf("failed to collect cpu profile: %w", err) }