Skip to content

Commit

Permalink
fix: performance test regression
Browse files Browse the repository at this point in the history
  • Loading branch information
SimoneLazzaris committed Dec 27, 2023
1 parent cb1de79 commit 601b1de
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/performance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ jobs:
./perf-test-suite $ARG_DURATION -host $INFLUX_HOST -token $INFLUX_TOKEN -runner ${{ matrix.target.name }} -version $(cat Makefile | grep '\<VERSION=' | awk -F= '{print $2}' | tr -d [\',]) > perf-test-results-with-summaries.txt
echo "duration=$SECONDS" >> $GITHUB_ENV
sed '/^{/,/^}/!d' perf-test-results-with-summaries.txt > perf-test-results.json
env:
GOMEMLIMIT: 76808MiB
- name: Upload test results
uses: actions/upload-artifact@v3
with:
Expand Down
3 changes: 2 additions & 1 deletion test/performance-test-suite/cmd/perf-test/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func main() {
flInfluxBucket := flag.String("bucket", "immudb-tests-results", "bucket for influxdb")
flInfluxRunner := flag.String("runner", "", "github runner for influxdb")
flInfluxVersion := flag.String("version", "", "immudb version for influxdb")
flTempDir := flag.String("workdir", "/tmp", "working dir path")

flag.Parse()

Expand All @@ -50,7 +51,7 @@ func main() {
*flSeed = binary.BigEndian.Uint64(rndSeed[:])
}

results, err := runner.RunAllBenchmarks(*flDuration, *flSeed)
results, err := runner.RunAllBenchmarks(*flDuration, *flTempDir, *flSeed)
if err != nil {
log.Fatal(err)
}
Expand Down
2 changes: 1 addition & 1 deletion test/performance-test-suite/pkg/benchmarks/benchmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type Benchmark interface {
Name() string

// Do a test warmup
Warmup() error
Warmup(workingDirectory string) error

// Cleanup after the test
Cleanup() error
Expand Down
21 changes: 13 additions & 8 deletions test/performance-test-suite/pkg/benchmarks/writetxs/benchmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ type benchmark struct {
primaryServer *server.ImmuServer
replicaServer *server.ImmuServer
clients []client.ImmuClient
tempDirs []string
}

type Result struct {
Expand Down Expand Up @@ -110,13 +111,12 @@ func (b *benchmark) Name() string {
return b.cfg.Name
}

func (b *benchmark) Warmup() error {
primaryPath, err := os.MkdirTemp("", "tx-test-primary")
func (b *benchmark) Warmup(tempDirBase string) error {
primaryPath, err := os.MkdirTemp(tempDirBase, "tx-test-primary")
if err != nil {
return err
}

defer os.RemoveAll(primaryPath)
b.tempDirs=append(b.tempDirs,primaryPath)

primaryServerOpts := server.
DefaultOptions().
Expand Down Expand Up @@ -154,12 +154,12 @@ func (b *benchmark) Warmup() error {
primaryPort := b.primaryServer.Listener.Addr().(*net.TCPAddr).Port

if b.cfg.Replica == "async" || b.cfg.Replica == "sync" {
replicaPath, err := os.MkdirTemp("", fmt.Sprintf("%s-tx-test-replica", b.cfg.Replica))
replicaPath, err := os.MkdirTemp(tempDirBase, fmt.Sprintf("%s-tx-test-replica", b.cfg.Replica))
if err != nil {
return err
}

defer os.RemoveAll(replicaPath)
b.tempDirs=append(b.tempDirs,replicaPath)

replicaServerOptions := server.
DefaultOptions().
Expand Down Expand Up @@ -207,7 +207,7 @@ func (b *benchmark) Warmup() error {

b.clients = []client.ImmuClient{}
for i := 0; i < b.cfg.Workers; i++ {
path, err := os.MkdirTemp("", "immudb_client")
path, err := os.MkdirTemp(tempDirBase, "immudb_client")
if err != nil {
return err
}
Expand All @@ -219,6 +219,7 @@ func (b *benchmark) Warmup() error {
}

b.clients = append(b.clients, c)
b.tempDirs = append(b.tempDirs, path)
}

return nil
Expand All @@ -234,11 +235,15 @@ func (b *benchmark) Cleanup() error {
}

b.primaryServer.Stop()
b.primaryServer = nil

if b.replicaServer != nil {
b.replicaServer.Stop()
b.replicaServer = nil
}
for _,tDir := range(b.tempDirs) {
os.RemoveAll(tDir)
}

return nil
}

Expand Down
4 changes: 1 addition & 3 deletions test/performance-test-suite/pkg/runner/benchmarks.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ func getBenchmarksToRun() []benchmarks.Benchmark {
AsyncWrite: true,
Replica: "async",
}),

writetxs.NewBenchmark(writetxs.Config{
writetxs.NewBenchmark(writetxs.Config{ // this one!
Name: "Write KV/s async - one async replica",
Workers: 30,
BatchSize: 1000,
Expand All @@ -62,7 +61,6 @@ func getBenchmarksToRun() []benchmarks.Benchmark {
AsyncWrite: true,
Replica: "async",
}),

writetxs.NewBenchmark(writetxs.Config{
Name: "Write TX/s async - one sync replica",
Workers: 30,
Expand Down
4 changes: 2 additions & 2 deletions test/performance-test-suite/pkg/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/codenotary/immudb/test/performance-test-suite/pkg/benchmarks/writetxs"
)

func RunAllBenchmarks(d time.Duration, seed uint64) (*BenchmarkSuiteResult, error) {
func RunAllBenchmarks(d time.Duration, tempDir string, seed uint64) (*BenchmarkSuiteResult, error) {
ret := &BenchmarkSuiteResult{
StartTime: time.Now(),
ProcessInfo: gatherProcessInfo(),
Expand All @@ -43,7 +43,7 @@ func RunAllBenchmarks(d time.Duration, seed uint64) (*BenchmarkSuiteResult, erro
Timeline: []BenchmarkTimelineEntry{},
}

err := b.Warmup()
err := b.Warmup(tempDir)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 601b1de

Please sign in to comment.