diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index aa67b5aef..796c661bc 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -284,13 +284,13 @@ Small, ad-hoc changes/PRs to Helm which introduce user facing changes, which wou ### Testing PRs -During development, you need to add automated tests where possible. There are a few `make test*` targets that you can use to execute your unit or integration tests. If your contribution requires profiling to check memory and/or CPU usage, you can use `--cpuprofile` and/or `--memprofile` global cli flags to run collect runtime profiling data for analysis. You can use Golang's [pprof](https://github.com/google/pprof/blob/main/doc/README.md) tool to inspect the profiling data. +During development, you need to add automated tests where possible. There are a few `make test*` targets that you can use to execute your unit or integration tests. If your contribution requires profiling to check memory and/or CPU usage, you can use `--cpuprofile` and/or `--memprofile` global cli flags to collect runtime profiling data for analysis. You can use Golang's [pprof](https://github.com/google/pprof/blob/main/doc/README.md) tool to inspect the results. -Example invocation that collects profiling data +Example analysing collected profiling data ``` helm show all bitnami/nginx --memprofile mem.prof --cpuprofile cpu.prof -# Visualize graphs. You need to have installed graphviz in you system +# Visualize graphs. You need to have installed graphviz package in your system go tool pprof -http=":8000" cpu.prof ``` diff --git a/cmd/helm/profiling.go b/cmd/helm/profiling.go index 090532416..e1ca62853 100644 --- a/cmd/helm/profiling.go +++ b/cmd/helm/profiling.go @@ -1,4 +1,18 @@ -// Profile CPU and memory usage of Helm commands +/* +Copyright The Helm Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ package main diff --git a/cmd/helm/root.go b/cmd/helm/root.go index fa1e6c6d0..50cb87e37 100644 --- a/cmd/helm/root.go +++ b/cmd/helm/root.go @@ -95,7 +95,7 @@ func newRootCmd(actionConfig *action.Configuration, out io.Writer, args []string Short: "The Helm package manager for Kubernetes.", Long: globalUsage, SilenceUsage: true, - PersistentPreRun: func(cmd *cobra.Command, args []string) { + PersistentPreRun: func(cmd *cobra.Command, _ []string) { cpuprof, err := cmd.Flags().GetString("cpuprofile") if err != nil { log.Printf("Warning: Failed to get cpuprofile flag: %v", err) @@ -105,7 +105,7 @@ func newRootCmd(actionConfig *action.Configuration, out io.Writer, args []string log.Printf("Warning: Failed to start profiling: %v", err) } }, - PersistentPostRun: func(cmd *cobra.Command, args []string) { + PersistentPostRun: func(cmd *cobra.Command, _ []string) { memprof, err := cmd.Flags().GetString("memprofile") if err != nil { log.Printf("Warning: Failed to get memprofile flag: %v", err)