Skip to content

Commit

Permalink
Implement profiling in clusterloader
Browse files Browse the repository at this point in the history
  • Loading branch information
mborsz committed Jun 30, 2022
1 parent 4dd3c06 commit 85159a1
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions clusterloader2/cmd/clusterloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ package main
import (
"fmt"
"io/ioutil"
"net/http"
_ "net/http/pprof"
"os"
"path"
"time"
Expand Down Expand Up @@ -59,6 +61,7 @@ var (
providerInitOptions provider.InitOptions
testConfigPaths []string
testSuiteConfigPath string
port int
)

func initClusterFlags() {
Expand Down Expand Up @@ -123,6 +126,7 @@ func initFlags() {
flags.StringArrayVar(&testConfigPaths, "testconfig", []string{}, "Paths to the test config files")
flags.StringArrayVar(&clusterLoaderConfig.OverridePaths, "testoverrides", []string{}, "Paths to the config overrides file. The latter overrides take precedence over changes in former files.")
flags.StringVar(&testSuiteConfigPath, "testsuite", "", "Path to the test suite config file")
flags.IntVar(&port, "port", 8000, "Port to be used by http server with pprof.")
initClusterFlags()
execservice.InitFlags(&clusterLoaderConfig.ExecServiceConfig)
modifier.InitFlags(&clusterLoaderConfig.ModifierConfig)
Expand Down Expand Up @@ -255,6 +259,13 @@ func main() {
klog.Exitf("Flag parse failed: %v", err)
}

// Start http server with pprof.
go func() {
klog.Infof("Listening on %d", port)
err := http.ListenAndServe(fmt.Sprintf("localhost:%d", port), nil)
klog.Errorf("http server unexpectedly ended: %v", err)
}()

provider, err := provider.NewProvider(&providerInitOptions)
if err != nil {
klog.Exitf("Error init provider: %v", err)
Expand Down

0 comments on commit 85159a1

Please sign in to comment.