Skip to content

Commit

Permalink
add pprof
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubuntu committed Nov 21, 2024
1 parent 953397b commit aef3436
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 3 deletions.
6 changes: 6 additions & 0 deletions disperser/apiserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,12 @@ func (s *DispersalServer) GetRateConfig() *RateConfig {
}

func (s *DispersalServer) Start(ctx context.Context) error {
pprofProfiler := NewPprofProfiler(s.serverConfig.PprofHttpPort, s.logger)

Check failure on line 822 in disperser/apiserver/server.go

View workflow job for this annotation

GitHub Actions / Linter

undefined: NewPprofProfiler (typecheck)

Check failure on line 822 in disperser/apiserver/server.go

View workflow job for this annotation

GitHub Actions / Linter

undefined: NewPprofProfiler) (typecheck)

Check failure on line 822 in disperser/apiserver/server.go

View workflow job for this annotation

GitHub Actions / Linter

undefined: NewPprofProfiler) (typecheck)

Check failure on line 822 in disperser/apiserver/server.go

View workflow job for this annotation

GitHub Actions / Linter

undefined: NewPprofProfiler) (typecheck)

Check failure on line 822 in disperser/apiserver/server.go

View workflow job for this annotation

GitHub Actions / Linter

undefined: NewPprofProfiler (typecheck)
if s.serverConfig.EnablePprof {
go pprofProfiler.Start(s.logger)
s.logger.Info("Enabled pprof for disperser apiserver", "port", s.serverConfig.PprofHttpPort)
}

go func() {
t := time.NewTicker(s.rateConfig.AllowlistRefreshInterval)
defer t.Stop()
Expand Down
6 changes: 4 additions & 2 deletions disperser/cmd/apiserver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,10 @@ func NewConfig(ctx *cli.Context) (Config, error) {
DisperserVersion: DisperserVersion(version),
AwsClientConfig: aws.ReadClientConfig(ctx, flags.FlagPrefix),
ServerConfig: disperser.ServerConfig{
GrpcPort: ctx.GlobalString(flags.GrpcPortFlag.Name),
GrpcTimeout: ctx.GlobalDuration(flags.GrpcTimeoutFlag.Name),
GrpcPort: ctx.GlobalString(flags.GrpcPortFlag.Name),
GrpcTimeout: ctx.GlobalDuration(flags.GrpcTimeoutFlag.Name),
PprofHttpPort: ctx.GlobalString(flags.PprofHttpPort.Name),
EnablePprof: ctx.GlobalBool(flags.EnablePprof.Name),
},
BlobstoreConfig: blobstore.Config{
BucketName: ctx.GlobalString(flags.S3BucketNameFlag.Name),
Expand Down
15 changes: 15 additions & 0 deletions disperser/cmd/apiserver/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,19 @@ var (
EnvVar: common.PrefixEnvVar(envVarPrefix, "MAX_NUM_SYMBOLS_PER_BLOB"),
Required: false,
}
PprofHttpPort = cli.StringFlag{
Name: common.PrefixFlag(FlagPrefix, "pprof-http-port"),
Usage: "the http port which the pprof server is listening",
Required: false,
Value: "6060",
EnvVar: common.PrefixEnvVar(envVarPrefix, "PPROF_HTTP_PORT"),
}
EnablePprof = cli.BoolFlag{
Name: common.PrefixFlag(FlagPrefix, "enable-pprof"),
Usage: "start prrof server",
Required: false,
EnvVar: common.PrefixEnvVar(envVarPrefix, "ENABLE_PPROF"),
}
)

var kzgFlags = []cli.Flag{
Expand Down Expand Up @@ -246,6 +259,8 @@ var optionalFlags = []cli.Flag{
GlobalRateTableName,
OnchainStateRefreshInterval,
MaxNumSymbolsPerBlob,
PprofHttpPort,
EnablePprof,
}

// Flags contains the list of configuration options available to the binary.
Expand Down
3 changes: 3 additions & 0 deletions disperser/server_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@ const (
type ServerConfig struct {
GrpcPort string
GrpcTimeout time.Duration

PprofHttpPort string
EnablePprof bool
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ require (
go.uber.org/mock v0.4.0
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa
golang.org/x/sync v0.8.0
golang.org/x/time v0.5.0
google.golang.org/grpc v1.64.1
)

Expand Down Expand Up @@ -151,7 +152,6 @@ require (
go.uber.org/zap v1.27.0 // indirect
golang.org/x/arch v0.4.0 // indirect
golang.org/x/oauth2 v0.22.0 // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240827150818-7e3bb234dfed // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
Expand Down

0 comments on commit aef3436

Please sign in to comment.