Skip to content

Commit

Permalink
feat(benchmark): use gops to diagnose benchmark tool
Browse files Browse the repository at this point in the history
This pull request adds the gops agent into the benchmark tool, making it easier
to diagnose.

Refs:
- https://github.com/google/gops
  • Loading branch information
ijsong committed Feb 25, 2024
1 parent 17905f3 commit c387533
Show file tree
Hide file tree
Showing 11 changed files with 493 additions and 9 deletions.
28 changes: 23 additions & 5 deletions cmd/benchmark/test_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"strings"

"github.com/google/gops/agent"
"github.com/urfave/cli/v2"

"github.com/kakao/varlog/internal/benchmark"
Expand Down Expand Up @@ -45,6 +46,12 @@ var (
Category: "Common: ",
Usage: "Use single connection shared by appenders in a target. Each target uses different connection.",
}
flagGopsAddr = &cli.StringFlag{
Name: "gops-addr",
Category: "Common: ",
Value: ":0",
Usage: "The address of gops agent",
}

flagAppenders = &cli.UintSliceFlag{
Name: "appenders",
Expand Down Expand Up @@ -94,17 +101,21 @@ func newCommandTest() *cli.Command {
Usage: "run benchmark test",
Flags: []cli.Flag{
flagClusterID,

flagTarget,
flagMRAddrs,
flagMsgSize,
flagBatchSize,
flagAppenders,
flagSubscribers,
flagDuration,
flagReportInterval,
flagPrintJSON,
flagPipelineSize,
flagSingleConnPerTarget,
flagGopsAddr,

Check warning on line 111 in cmd/benchmark/test_command.go

View check run for this annotation

Codecov / codecov/patch

cmd/benchmark/test_command.go#L111

Added line #L111 was not covered by tests

flagAppenders,
flagMsgSize,
flagBatchSize,
flagPipelineSize,

Check warning on line 116 in cmd/benchmark/test_command.go

View check run for this annotation

Codecov / codecov/patch

cmd/benchmark/test_command.go#L113-L116

Added lines #L113 - L116 were not covered by tests

flagSubscribers,

Check warning on line 118 in cmd/benchmark/test_command.go

View check run for this annotation

Codecov / codecov/patch

cmd/benchmark/test_command.go#L118

Added line #L118 was not covered by tests
flagSubscribeSize,
},
Action: runCommandTest,
Expand All @@ -116,6 +127,13 @@ func runCommandTest(c *cli.Context) error {
return fmt.Errorf("unexpected args: %v", c.Args().Slice())
}

if err := agent.Listen(agent.Options{
Addr: c.String(flagGopsAddr.Name),
}); err != nil {
return err

Check warning on line 133 in cmd/benchmark/test_command.go

View check run for this annotation

Codecov / codecov/patch

cmd/benchmark/test_command.go#L130-L133

Added lines #L130 - L133 were not covered by tests
}
defer agent.Close()

Check warning on line 135 in cmd/benchmark/test_command.go

View check run for this annotation

Codecov / codecov/patch

cmd/benchmark/test_command.go#L135

Added line #L135 was not covered by tests

clusterID, err := types.ParseClusterID(c.String(flagClusterID.Name))
if err != nil {
return err
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ require (
github.com/gogo/protobuf v1.3.2
github.com/gogo/status v1.1.1
github.com/golang/protobuf v1.5.3
github.com/google/gops v0.3.28
github.com/lib/pq v1.10.9
github.com/pkg/errors v0.9.1
github.com/puzpuzpuz/xsync/v2 v2.5.1
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/gops v0.3.28 h1:2Xr57tqKAmQYRAfG12E+yLcoa2Y42UJo2lOrUFL9ark=
github.com/google/gops v0.3.28/go.mod h1:6f6+Nl8LcHrzJwi8+p0ii+vmBFSlB4f8cOOkTJ7sk4c=
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
Expand Down
5 changes: 1 addition & 4 deletions internal/benchmark/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,8 @@ func (loader *Loader) subscribeLoop(ctx context.Context, c varlog.Log) error {
}

func (loader *Loader) subscribeLoopInternal(ctx context.Context, c varlog.Log, first, last varlogpb.LogSequenceNumber) error {
subscribeSize := types.GLSN(loader.SubscribeSize)

loader.logger.Info("subscribe", slog.Any("first", first), slog.Any("last", last), slog.Int("subscribeSize", loader.SubscribeSize))

var sm SubscribeMetrics
subscribeSize := types.GLSN(loader.SubscribeSize)

Check warning on line 252 in internal/benchmark/loader.go

View check run for this annotation

Codecov / codecov/patch

internal/benchmark/loader.go#L252

Added line #L252 was not covered by tests
begin := first.GLSN
end := min(begin+subscribeSize, last.GLSN+1)
for begin < end {
Expand Down
27 changes: 27 additions & 0 deletions vendor/github.com/google/gops/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c387533

Please sign in to comment.