From 601b1dec01ddae3fac7a39f69d602635c3eb52a9 Mon Sep 17 00:00:00 2001 From: Simone Lazzaris Date: Thu, 21 Dec 2023 12:31:43 +0100 Subject: [PATCH] fix: performance test regression --- .github/workflows/performance.yml | 2 ++ .../cmd/perf-test/main.go | 3 ++- .../pkg/benchmarks/benchmark.go | 2 +- .../pkg/benchmarks/writetxs/benchmark.go | 21 ++++++++++++------- .../pkg/runner/benchmarks.go | 4 +--- .../pkg/runner/runner.go | 4 ++-- 6 files changed, 21 insertions(+), 15 deletions(-) diff --git a/.github/workflows/performance.yml b/.github/workflows/performance.yml index 351dfdee00..f3758f6d40 100644 --- a/.github/workflows/performance.yml +++ b/.github/workflows/performance.yml @@ -59,6 +59,8 @@ jobs: ./perf-test-suite $ARG_DURATION -host $INFLUX_HOST -token $INFLUX_TOKEN -runner ${{ matrix.target.name }} -version $(cat Makefile | grep '\ 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: diff --git a/test/performance-test-suite/cmd/perf-test/main.go b/test/performance-test-suite/cmd/perf-test/main.go index 3a5448bdc9..429f74398a 100644 --- a/test/performance-test-suite/cmd/perf-test/main.go +++ b/test/performance-test-suite/cmd/perf-test/main.go @@ -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() @@ -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) } diff --git a/test/performance-test-suite/pkg/benchmarks/benchmark.go b/test/performance-test-suite/pkg/benchmarks/benchmark.go index 61eda4527e..d262b288d9 100644 --- a/test/performance-test-suite/pkg/benchmarks/benchmark.go +++ b/test/performance-test-suite/pkg/benchmarks/benchmark.go @@ -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 diff --git a/test/performance-test-suite/pkg/benchmarks/writetxs/benchmark.go b/test/performance-test-suite/pkg/benchmarks/writetxs/benchmark.go index b1c622d099..81e0a28d3b 100644 --- a/test/performance-test-suite/pkg/benchmarks/writetxs/benchmark.go +++ b/test/performance-test-suite/pkg/benchmarks/writetxs/benchmark.go @@ -68,6 +68,7 @@ type benchmark struct { primaryServer *server.ImmuServer replicaServer *server.ImmuServer clients []client.ImmuClient + tempDirs []string } type Result struct { @@ -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(). @@ -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(). @@ -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 } @@ -219,6 +219,7 @@ func (b *benchmark) Warmup() error { } b.clients = append(b.clients, c) + b.tempDirs = append(b.tempDirs, path) } return nil @@ -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 } diff --git a/test/performance-test-suite/pkg/runner/benchmarks.go b/test/performance-test-suite/pkg/runner/benchmarks.go index e1114fa8c0..57948765ed 100644 --- a/test/performance-test-suite/pkg/runner/benchmarks.go +++ b/test/performance-test-suite/pkg/runner/benchmarks.go @@ -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, @@ -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, diff --git a/test/performance-test-suite/pkg/runner/runner.go b/test/performance-test-suite/pkg/runner/runner.go index d5454145d9..0ee2bba1b5 100644 --- a/test/performance-test-suite/pkg/runner/runner.go +++ b/test/performance-test-suite/pkg/runner/runner.go @@ -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(), @@ -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 }