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

Impl benchmark jobs #1977

Merged
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/dockers-benchmark-job-image.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (C) 2019-2022 vdaas.org vald team <[email protected]>
# Copyright (C) 2019-2023 vdaas.org vald team <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion apis/grpc/v1/benchmark/benchmark.pb.go

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

2 changes: 1 addition & 1 deletion apis/grpc/v1/benchmark/benchmark_vtproto.pb.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright (C) 2019-2022 vdaas.org vald team <[email protected]>
// Copyright (C) 2019-2023 vdaas.org vald team <[email protected]>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion apis/proto/v1/benchmark/benchmark.proto
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright (C) 2019-2022 vdaas.org vald team <[email protected]>
// Copyright (C) 2019-2023 vdaas.org vald team <[email protected]>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion cmd/tools/benchmark/job/main.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright (C) 2019-2022 vdaas.org vald team <[email protected]>
// Copyright (C) 2019-2023 vdaas.org vald team <[email protected]>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion cmd/tools/benchmark/job/sample.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (C) 2019-2022 vdaas.org vald team <[email protected]>
# Copyright (C) 2019-2023 vdaas.org vald team <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion cmd/tools/benchmark/operator/main.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright (C) 2019-2022 vdaas.org vald team <[email protected]>
// Copyright (C) 2019-2023 vdaas.org vald team <[email protected]>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,7 @@ require (
go.opentelemetry.io/otel/trace v1.11.2
go.uber.org/automaxprocs v0.0.0-00010101000000-000000000000
go.uber.org/goleak v1.2.0
go.uber.org/ratelimit v0.2.0
go.uber.org/zap v1.24.0
gocloud.dev v0.0.0-00010101000000-000000000000
golang.org/x/exp v0.0.0-20220827204233-334a2380cb91
Expand All @@ -549,6 +550,7 @@ require (
golang.org/x/sync v0.1.0
golang.org/x/sys v0.7.0
golang.org/x/text v0.9.0
golang.org/x/time v0.3.0
golang.org/x/tools v0.7.0
gonum.org/v1/hdf5 v0.0.0-00010101000000-000000000000
gonum.org/v1/plot v0.10.1
Expand All @@ -573,6 +575,7 @@ require (
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver v1.5.0 // indirect
github.com/ajstarks/svgo v0.0.0-20211024235047-1546f124cd8b // indirect
github.com/andres-erbsen/clock v0.0.0-20160526145045-9e14626cd129 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
Expand Down Expand Up @@ -645,7 +648,6 @@ require (
golang.org/x/image v0.6.0 // indirect
golang.org/x/mod v0.10.0 // indirect
golang.org/x/term v0.7.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
google.golang.org/api v0.114.0 // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ github.com/ajstarks/openvg v0.0.0-20191008131700-c6885d824eb8/go.mod h1:jpZHIkd4
github.com/ajstarks/svgo v0.0.0-20211024235047-1546f124cd8b h1:slYM766cy2nI3BwyRiyQj/Ud48djTMtMebDqepE95rw=
github.com/ajstarks/svgo v0.0.0-20211024235047-1546f124cd8b/go.mod h1:1KcenG0jGWcpt8ov532z81sp/kMMUG485J2InIOyADM=
github.com/akavel/rsrc v0.8.0/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c=
github.com/andres-erbsen/clock v0.0.0-20160526145045-9e14626cd129 h1:MzBOUgng9orim59UnfUTLRjMpd09C5uEVQ6RPGeCaVI=
github.com/andres-erbsen/clock v0.0.0-20160526145045-9e14626cd129/go.mod h1:rFgpPQZYZ8vdbc+48xibu8ALc3yeyd64IhHS+PU6Yyg=
github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/apache/arrow/go/v11 v11.0.0/go.mod h1:Eg5OsL5H+e299f7u5ssuXsuHQVEGC4xei5aX110hRiI=
Expand Down Expand Up @@ -662,6 +664,8 @@ go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A=
go.uber.org/goleak v1.2.1/go.mod h1:qlT2yGI9QafXHhZZLxlSuNsMw3FFLxBr+tBRlmO1xH4=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/ratelimit v0.2.0 h1:UQE2Bgi7p2B85uP5dC2bbRtig0C+OeNRnNEafLjsLPA=
go.uber.org/ratelimit v0.2.0/go.mod h1:YYBV4e4naJvhpitQrWJu1vCpgB7CboMe0qhltKt6mUg=
go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60=
go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg=
gocloud.dev v0.29.0 h1:fBy0jwJSmxs0IjT0fE32MO+Mj+307VZQwyHaTyFZbC4=
Expand Down
156 changes: 131 additions & 25 deletions internal/config/benchmark.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright (C) 2019-2022 vdaas.org vald team <[email protected]>
// Copyright (C) 2019-2023 vdaas.org vald team <[email protected]>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -17,33 +17,32 @@
// Package config providers configuration type and load configuration logic
package config

import "github.com/vdaas/vald/internal/k8s/client"

// BenchmarkJob represents the configuration for the internal benchmark search job.
type BenchmarkJob struct {
Target *BenchmarkTarget `json:"target,omitempty" yaml:"target"`
Dataset *BenchmarkDataset `json:"dataset,omitempty" yaml:"dataset"`
Dimension int `json:"dimension,omitempty" yaml:"dimension"`
Replica int `json:"replica,omitempty" yaml:"replica"`
Repetition int `json:"repetition,omitempty" yaml:"repetition"`
JobType string `json:"job_type,omitempty" yaml:"job_type"`
InsertConfig *InsertConfig `json:"insert_config,omitempty" yaml:"insert_config"`
UpdateConfig *UpdateConfig `json:"update_config,omitempty" yaml:"update_config"`
UpsertConfig *UpsertConfig `json:"upsert_config,omitempty" yaml:"upsert_config"`
SearchConfig *SearchConfig `json:"search_config,omitempty" yaml:"search_config"`
RemoveConfig *RemoveConfig `json:"remove_config,omitempty" yaml:"remove_config"`
ClientConfig *GRPCClient `json:"client_config,omitempty" yaml:"client_config"`
Rules []*BenchmarkJobRule `json:"rules,omitempty" yaml:"rules"`
BeforeJobName string `json:"before_job_name,omitempty" yaml:"before_job_name"`
Target *BenchmarkTarget `json:"target,omitempty" yaml:"target"`
Dataset *BenchmarkDataset `json:"dataset,omitempty" yaml:"dataset"`
Dimension int `json:"dimension,omitempty" yaml:"dimension"`
Replica int `json:"replica,omitempty" yaml:"replica"`
Repetition int `json:"repetition,omitempty" yaml:"repetition"`
JobType string `json:"job_type,omitempty" yaml:"job_type"`
InsertConfig *InsertConfig `json:"insert_config,omitempty" yaml:"insert_config"`
UpdateConfig *UpdateConfig `json:"update_config,omitempty" yaml:"update_config"`
UpsertConfig *UpsertConfig `json:"upsert_config,omitempty" yaml:"upsert_config"`
SearchConfig *SearchConfig `json:"search_config,omitempty" yaml:"search_config"`
RemoveConfig *RemoveConfig `json:"remove_config,omitempty" yaml:"remove_config"`
ObjectConfig *ObjectConfig `json:"object_config,omitempty" yaml:"object_config"`
ClientConfig *GRPCClient `json:"client_config,omitempty" yaml:"client_config"`
Rules []*BenchmarkJobRule `json:"rules,omitempty" yaml:"rules"`
BeforeJobName string `json:"before_job_name,omitempty" yaml:"before_job_name"`
BeforeJobNamespace string `json:"before_job_namespace,omitempty" yaml:"before_job_namespace"`
Client client.Client `json:"client,omitempty" yaml:"client"`
RPS int `json:"rps,omitempty" yaml:"rps"`
}

// BenchmarkScenario represents the configuration for the internal benchmark scenario.
type BenchmarkScenario struct {
Target *BenchmarkTarget `json:"target" yaml:"target"`
Dataset *BenchmarkDataset `jon:"dataset" yaml:"dataset"`
Jobs []*BenchmarkJob `job:"jobs" yaml:jobs`
Target *BenchmarkTarget `json:"target,omitempty" yaml:"target"`
Dataset *BenchmarkDataset `json:"dataset,omitempty" yaml:"dataset"`
Jobs []*BenchmarkJob `json:"jobs,omitempty" yaml:"jobs"`
}

// BenchmarkTarget defines the desired state of BenchmarkTarget
Expand All @@ -52,6 +51,11 @@ type BenchmarkTarget struct {
Port int `json:"port,omitempty"`
}

func (t *BenchmarkTarget) Bind() *BenchmarkTarget {
t.Host = GetActualValue(t.Host)
return t
}

// BenchmarkDataset defines the desired state of BenchmarkDateset
type BenchmarkDataset struct {
Name string `json:"name,omitempty"`
Expand All @@ -60,6 +64,11 @@ type BenchmarkDataset struct {
Range *BenchmarkDatasetRange `json:"range,omitempty"`
}

func (d *BenchmarkDataset) Bind() *BenchmarkDataset {
d.Name = GetActualValue(d.Name)
return d
}

// BenchmarkDatasetRange defines the desired state of BenchmarkDatesetRange
type BenchmarkDatasetRange struct {
Start int `json:"start,omitempty"`
Expand All @@ -72,22 +81,45 @@ type BenchmarkJobRule struct {
Type string `json:"type,omitempty"`
}

func (r *BenchmarkJobRule) Bind() *BenchmarkJobRule {
r.Name = GetActualValue(r.Name)
r.Type = GetActualValue(r.Type)
return r
}

// InsertConfig defines the desired state of insert config
type InsertConfig struct {
SkipStrictExistCheck bool `json:"skip_strict_exist_check,omitempty"`
Timestamp string `json:"timestamp,omitempty"`
}

func (cfg *InsertConfig) Bind() *InsertConfig {
cfg.Timestamp = GetActualValue(cfg.Timestamp)
return cfg
}

// UpdateConfig defines the desired state of update config
type UpdateConfig struct {
SkipStrictExistCheck bool `json:"skip_strict_exist_check,omitempty"`
Timestamp string `json:"timestamp,omitempty"`
SkipStrictExistCheck bool `json:"skip_strict_exist_check,omitempty"`
Timestamp string `json:"timestamp,omitempty"`
DisableBalancedUpdate bool `json:"disable_balanced_update,omitempty"`
}

func (cfg *UpdateConfig) Bind() *UpdateConfig {
cfg.Timestamp = GetActualValue(cfg.Timestamp)
return cfg
}

// UpsertConfig defines the desired state of upsert config
type UpsertConfig struct {
SkipStrictExistCheck bool `json:"skip_strict_exist_check,omitempty"`
Timestamp string `json:"timestamp,omitempty"`
SkipStrictExistCheck bool `json:"skip_strict_exist_check,omitempty"`
Timestamp string `json:"timestamp,omitempty"`
DisableBalancedUpdate bool `json:"disable_balanced_update,omitempty"`
}

func (cfg *UpsertConfig) Bind() *UpsertConfig {
cfg.Timestamp = GetActualValue(cfg.Timestamp)
return cfg
}

// SearchConfig defines the desired state of search config
Expand All @@ -99,19 +131,93 @@ type SearchConfig struct {
Timeout string `json:"timeout,omitempty"`
}

func (cfg *SearchConfig) Bind() *SearchConfig {
cfg.Timeout = GetActualValue(cfg.Timeout)
return cfg
}

// RemoveConfig defines the desired state of remove config
type RemoveConfig struct {
SkipStrictExistCheck bool `json:"skip_strict_exist_check,omitempty"`
Timestamp string `json:"timestamp,omitempty"`
}

func (cfg *RemoveConfig) Bind() *RemoveConfig {
cfg.Timestamp = GetActualValue(cfg.Timestamp)
return cfg
}

// ObjectConfig defines the desired state of object config
type ObjectConfig struct {
FilterConfig FilterConfig `json:"filter_config,omitempty" yaml:"filter_config"`
}

func (cfg *ObjectConfig) Bind() *ObjectConfig {
cfg.FilterConfig = *cfg.FilterConfig.Bind()
return cfg
}

// FilterTarget defines the desired state of filter target
type FilterTarget struct {
Host string `json:"host,omitempty" yaml:"host"`
Port int32 `json:"port,omitempty" yaml:"port"`
}

func (cfg *FilterTarget) Bind() *FilterTarget {
cfg.Host = GetActualValue(cfg.Host)
return cfg
}

// FilterConfig defines the desired state of filter config
type FilterConfig struct {
Targets []*FilterTarget `json:"target,omitempty" yaml:"target"`
}

func (cfg *FilterConfig) Bind() *FilterConfig {
for i := 0; i < len(cfg.Targets); i++ {
cfg.Targets[i] = cfg.Targets[i].Bind()
}
return cfg
}

// Bind binds the actual data from the Job receiver fields.
func (b *BenchmarkJob) Bind() *BenchmarkJob {
b.JobType = GetActualValue(b.JobType)
b.BeforeJobName = GetActualValue(b.BeforeJobName)
b.BeforeJobNamespace = GetActualValue(b.BeforeJobNamespace)

if b.Target != nil {
b.Target = b.Target.Bind()
}
if b.Dataset != nil {
b.Dataset = b.Dataset.Bind()
}
if b.InsertConfig != nil {
b.InsertConfig = b.InsertConfig.Bind()
}
if b.UpdateConfig != nil {
b.UpdateConfig = b.UpdateConfig.Bind()
}
if b.UpsertConfig != nil {
b.UpsertConfig = b.UpsertConfig.Bind()
}
if b.SearchConfig != nil {
b.SearchConfig = b.SearchConfig.Bind()
}
if b.RemoveConfig != nil {
b.RemoveConfig = b.RemoveConfig.Bind()
}
if b.ObjectConfig != nil {
b.ObjectConfig = b.ObjectConfig.Bind()
}
if b.ClientConfig != nil {
b.ClientConfig = b.ClientConfig.Bind()
}
if len(b.Rules) > 0 {
for i := 0; i < len(b.Rules); i++ {
b.Rules[i] = b.Rules[i].Bind()
}
}
return b
}

Expand Down
5 changes: 5 additions & 0 deletions internal/errors/benchmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,9 @@ var (
ErrFailedToCreateJob = func(err error, jn string) error {
return Wrapf(err, "could not create job: %s ", jn)
}

// ErrMismatchBenchmarkAtomics represents a function to generate an error that mismatch each atomic.Pointer stored corresponding to benchmark tasks.
ErrMismatchBenchmarkAtomics = func(job, benchjob, benchscenario interface{}) error {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gochecknoglobals: ErrMismatchBenchmarkAtomics is a global variable


ℹ️ Expand to see all @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Help us improve LIFT! (Sonatype LiftBot external survey)

Was this a good recommendation for you? Answering this survey will not impact your Lift settings.

[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

return Errorf("mismatch atomics: job=%v\tbenchjob=%v\tbenchscenario=%v", job, benchjob, benchscenario)
}
)
2 changes: 1 addition & 1 deletion internal/k8s/client/client.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright (C) 2019-2022 vdaas.org vald team <[email protected]>
// Copyright (C) 2019-2023 vdaas.org vald team <[email protected]>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion internal/k8s/client/option.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright (C) 2019-2022 vdaas.org vald team <[email protected]>
// Copyright (C) 2019-2023 vdaas.org vald team <[email protected]>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
8 changes: 7 additions & 1 deletion internal/k8s/crd/benchmark/valdbenchmarkjob.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (C) 2019-2022 vdaas.org vald team <[email protected]>
# Copyright (C) 2019-2023 vdaas.org vald team <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -129,6 +129,8 @@ spec:
- type
type: object
type: array
rps:
type: integer
insert_config:
description: InsertConfig defines the desired state of insert config
properties:
Expand Down Expand Up @@ -168,6 +170,8 @@ spec:
type: boolean
timestamp:
type: string
disable_balanced_update:
type: boolean
type: object
upsert_config:
description: UpsertConfig defines the desired state of upsert config
Expand All @@ -176,6 +180,8 @@ spec:
type: boolean
timestamp:
type: string
disable_balanced_update:
type: boolean
type: object
client_config:
description: ClientConfig represents the configurations for gRPC client.
Expand Down
Loading