|
|
@ -17,11 +17,11 @@ limitations under the License.
|
|
|
|
package main
|
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
|
|
|
|
"errors"
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"os"
|
|
|
|
"runtime"
|
|
|
|
"runtime"
|
|
|
|
"runtime/pprof"
|
|
|
|
"runtime/pprof"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
var (
|
|
|
|
var (
|
|
|
@ -58,14 +58,14 @@ func startProfiling() error {
|
|
|
|
// It writes memory profile to the file path specified in HELM_PPROF_MEM_PROFILE
|
|
|
|
// It writes memory profile to the file path specified in HELM_PPROF_MEM_PROFILE
|
|
|
|
// environment variable.
|
|
|
|
// environment variable.
|
|
|
|
func stopProfiling() error {
|
|
|
|
func stopProfiling() error {
|
|
|
|
errs := []string{}
|
|
|
|
errs := []error{}
|
|
|
|
|
|
|
|
|
|
|
|
// Stop CPU profiling if it was started
|
|
|
|
// Stop CPU profiling if it was started
|
|
|
|
if cpuProfileFile != nil {
|
|
|
|
if cpuProfileFile != nil {
|
|
|
|
pprof.StopCPUProfile()
|
|
|
|
pprof.StopCPUProfile()
|
|
|
|
err := cpuProfileFile.Close()
|
|
|
|
err := cpuProfileFile.Close()
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
errs = append(errs, err.Error())
|
|
|
|
errs = append(errs, err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cpuProfileFile = nil
|
|
|
|
cpuProfileFile = nil
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -73,13 +73,13 @@ func stopProfiling() error {
|
|
|
|
if memProfilePath != "" {
|
|
|
|
if memProfilePath != "" {
|
|
|
|
f, err := os.Create(memProfilePath)
|
|
|
|
f, err := os.Create(memProfilePath)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
errs = append(errs, err.Error())
|
|
|
|
errs = append(errs, err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
defer f.Close()
|
|
|
|
defer f.Close()
|
|
|
|
|
|
|
|
|
|
|
|
runtime.GC() // get up-to-date statistics
|
|
|
|
runtime.GC() // get up-to-date statistics
|
|
|
|
if err := pprof.WriteHeapProfile(f); err != nil {
|
|
|
|
if err := pprof.WriteHeapProfile(f); err != nil {
|
|
|
|
errs = append(errs, err.Error())
|
|
|
|
errs = append(errs, err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|