Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DAOS-15510 control: Debug dmg performance #14592

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/control/cmd/daos_server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"context"
"encoding/json"
"fmt"
"log"
"os"
"path"

Expand All @@ -24,6 +25,9 @@ import (
"github.com/daos-stack/daos/src/control/lib/hardware/hwprov"
"github.com/daos-stack/daos/src/control/logging"
"github.com/daos-stack/daos/src/control/pbin"

"net/http"
_ "net/http/pprof"
)

const defaultConfigFile = "daos_server.yml"
Expand Down Expand Up @@ -171,6 +175,10 @@ func parseOpts(args []string, opts *mainOpts, log *logging.LeveledLogger) error
}

func main() {
go func() {
log.Println(http.ListenAndServe(":6060", nil))
}()

log := logging.NewCommandLineLogger()
opts := mainOpts{
preExecTests: []execTestFn{
Expand Down
42 changes: 33 additions & 9 deletions src/control/cmd/dmg/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ package main
import (
"encoding/json"
"fmt"
"log"
"os"
"path"
"runtime/pprof"
"strconv"

flags "github.com/jessevdk/go-flags"
"github.com/pkg/errors"
Expand Down Expand Up @@ -296,19 +299,40 @@ and access control settings, along with system wide operations.`
}

func main() {
n := 1
cpuprofile := os.Getenv("DAOS_DMG_CPUPROFILE")
if cpuprofile != "" {
f, err := os.Create(cpuprofile)
if err != nil {
log.Fatal(err)
}
nString := os.Getenv("DAOS_DMG_CPUPROFILE_N")
if nString == "" {
nString = "100"
}
n, err = strconv.Atoi(nString)
if err != nil {
log.Fatal(err)
}
pprof.StartCPUProfile(f)
defer pprof.StopCPUProfile()
}

var opts cliOptions
log := logging.NewCommandLineLogger()

ctlInvoker := control.NewClient(
control.WithClientLogger(log),
control.WithClientComponent(build.ComponentAdmin),
)
for i := 0; i < n; i++ {
ctlInvoker := control.NewClient(
control.WithClientLogger(log),
control.WithClientComponent(build.ComponentAdmin),
)

if err := parseOpts(os.Args[1:], &opts, ctlInvoker, log); err != nil {
if fe, ok := errors.Cause(err).(*flags.Error); ok && fe.Type == flags.ErrHelp {
log.Info(fe.Error())
os.Exit(0)
if err := parseOpts(os.Args[1:], &opts, ctlInvoker, log); err != nil {
if fe, ok := errors.Cause(err).(*flags.Error); ok && fe.Type == flags.ErrHelp {
log.Info(fe.Error())
os.Exit(0)
}
exitWithError(log, err)
}
exitWithError(log, err)
}
}
Loading