From a8e98e662933758cc6955141cb051e68c6b788a6 Mon Sep 17 00:00:00 2001 From: Tim Gross Date: Tue, 26 Mar 2024 12:19:18 +0000 Subject: [PATCH] backport of commit a50e6267d0d8cbde5d66c528604a69fef99e6618 --- .changelog/20219.txt | 3 +++ command/operator_debug.go | 23 ++++++++++++++++------- command/operator_debug_test.go | 1 - 3 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 .changelog/20219.txt diff --git a/.changelog/20219.txt b/.changelog/20219.txt new file mode 100644 index 00000000000..3312e846ec4 --- /dev/null +++ b/.changelog/20219.txt @@ -0,0 +1,3 @@ +```release-note:improvement +cli: Collect only one heap profile per `operator debug` interval +``` diff --git a/command/operator_debug.go b/command/operator_debug.go index ed3224758f7..7c6fe1b32c6 100644 --- a/command/operator_debug.go +++ b/command/operator_debug.go @@ -1034,22 +1034,31 @@ func (c *OperatorDebugCommand) collectPprof(path, id string, client *api.Client, } } - // goroutine debug type 1 = legacy text format for human readable output + // goroutine debug type 1 = goroutine in pprof text format (includes a count + // for each identical stack, pprof labels) opts.Debug = 1 c.savePprofProfile(path, "goroutine", opts, client, interval) - // goroutine debug type 2 = goroutine stacks in panic format + // goroutine debug type 2 = goroutine stacks in panic format (includes a + // stack for each goroutine, wait reason, no pprof labels) opts.Debug = 2 c.savePprofProfile(path, "goroutine", opts, client, interval) // Reset to pprof binary format opts.Debug = 0 - c.savePprofProfile(path, "goroutine", opts, client, interval) // Stack traces of all current goroutines - c.savePprofProfile(path, "trace", opts, client, interval) // A trace of execution of the current program - c.savePprofProfile(path, "heap", opts, client, interval) // A sampling of memory allocations of live objects. You can specify the gc GET parameter to run GC before taking the heap sample. - c.savePprofProfile(path, "allocs", opts, client, interval) // A sampling of all past memory allocations - c.savePprofProfile(path, "threadcreate", opts, client, interval) // Stack traces that led to the creation of new OS threads + // Stack traces of all current goroutines, binary format for `go tool pprof` + c.savePprofProfile(path, "goroutine", opts, client, interval) + + // A trace of execution of the current program + c.savePprofProfile(path, "trace", opts, client, interval) + + // A sampling of memory allocations of live objects. You can specify + // the gc GET parameter to run GC before taking the heap sample. + c.savePprofProfile(path, "heap", opts, client, interval) + + // Stack traces that led to the creation of new OS threads + c.savePprofProfile(path, "threadcreate", opts, client, interval) } // savePprofProfile retrieves a pprof profile and writes to disk diff --git a/command/operator_debug_test.go b/command/operator_debug_test.go index b8a7f981be4..9e811faadca 100644 --- a/command/operator_debug_test.go +++ b/command/operator_debug_test.go @@ -451,7 +451,6 @@ func TestDebug_CapturedFiles(t *testing.T) { } pprofFiles := []string{ - "allocs_0000.prof", "goroutine-debug1_0000.txt", "goroutine-debug2_0000.txt", "goroutine_0000.prof",