From 9fd091831de8bc221a81a5e6e611965641334200 Mon Sep 17 00:00:00 2001 From: Egon Elbre Date: Fri, 8 Oct 2021 16:36:58 +0300 Subject: [PATCH] ci: optimize benchmarks We are not using the benchmark results for anything, they are mostly there to ensure that we don't break the benchmarks. So we can disable CockroachDB for them. Similarly add short versions of other tests. Also try to precompile test/benchmark code. Change-Id: I60b501789f70c289af68c37a052778dc75ae2b69 --- Jenkinsfile.public | 9 ++++----- .../metainfo/piecedeletion/combiner_bench_test.go | 15 ++++++++------- storage/testsuite/bench.go | 3 +++ web/satellite/package.json | 1 + web/satellite/scripts/build-wasm-dev.sh | 7 +++++++ 5 files changed, 23 insertions(+), 12 deletions(-) create mode 100755 web/satellite/scripts/build-wasm-dev.sh diff --git a/Jenkinsfile.public b/Jenkinsfile.public index f89632ebd..9c2085ef1 100644 --- a/Jenkinsfile.public +++ b/Jenkinsfile.public @@ -51,11 +51,13 @@ pipeline { stage('go') { steps { sh 'go build -v ./...' + sh 'go test -v -p 16 -bench XYZXYZXYZXYZ -run XYZXYZXYZXYZ ./...' } } stage('go -race') { steps { sh 'go build -v -race ./...' + sh 'go test -v -p 16 -bench XYZXYZXYZXYZ -run XYZXYZXYZXYZ -race ./...' // install storj-sim sh 'go install -race -v storj.io/storj/cmd/satellite '+ @@ -92,11 +94,9 @@ pipeline { steps { dir('web/satellite') { sh 'npm ci --prefer-offline --no-audit' + sh 'npm run wasm-dev' sh 'npm run build' } - - sh 'cp "$(go env GOROOT)/misc/wasm/wasm_exec.js" web/satellite/static/wasm/wasm_exec.js' - sh 'GOOS=js GOARCH=wasm go build -o web/satellite/static/wasm/access.wasm storj.io/storj/satellite/console/wasm' } } stage('web/storagenode') { @@ -212,11 +212,10 @@ pipeline { stage('Check Benchmark') { environment { - STORJ_TEST_COCKROACH = 'cockroach://root@localhost:26256/benchcockroach?sslmode=disable' + STORJ_TEST_COCKROACH = 'omit' STORJ_TEST_POSTGRES = 'postgres://postgres@localhost/benchstorj?sslmode=disable' } steps { - sh 'cockroach sql --insecure --host=localhost:26256 -e \'create database benchcockroach;\'' sh 'psql -U postgres -c \'create database benchstorj;\'' sh 'go test -parallel 1 -p 1 -vet=off -timeout 20m -short -run XYZXYZXYZXYZ -bench . -benchtime 1x ./...' } diff --git a/satellite/metainfo/piecedeletion/combiner_bench_test.go b/satellite/metainfo/piecedeletion/combiner_bench_test.go index 2332d326a..13efb8740 100644 --- a/satellite/metainfo/piecedeletion/combiner_bench_test.go +++ b/satellite/metainfo/piecedeletion/combiner_bench_test.go @@ -48,7 +48,7 @@ func (handler *SleepyHandler) Handle(ctx context.Context, node storj.NodeURL, qu } func BenchmarkCombiner(b *testing.B) { - const ( + var ( // currently nodes are picked uniformly, however total piece distribution is not // hence we use a lower number to simulate frequent nodes nodeCount = 500 @@ -58,17 +58,18 @@ func BenchmarkCombiner(b *testing.B) { // we cannot use realistic values here due to sleep granularity minWait = 1 * time.Millisecond maxWait = 20 * time.Millisecond + // add few variations to test + activeLimits = []int{8, 32, 64, -1} + queueSizes = []int{1, 8, 64, 128, -1} ) - var activeLimits []int - var queueSizes []int - if testing.Short() { + // use values to make tests run faster + nodeCount = 5 + requestCount = 5 + callsPerRequest = 5 activeLimits = []int{8, 64, -1} queueSizes = []int{8, 128, -1} - } else { - activeLimits = []int{8, 32, 64, -1} - queueSizes = []int{1, 8, 64, 128, -1} } nodes := []storj.NodeURL{} diff --git a/storage/testsuite/bench.go b/storage/testsuite/bench.go index 5c993835a..34ff619e9 100644 --- a/storage/testsuite/bench.go +++ b/storage/testsuite/bench.go @@ -24,6 +24,9 @@ func RunBenchmarks(b *testing.B, store storage.KeyValueStore) { } words = words[:20] // branching factor + if testing.Short() { + words = words[:2] + } var items storage.Items diff --git a/web/satellite/package.json b/web/satellite/package.json index 90c93cad3..f034d47fe 100644 --- a/web/satellite/package.json +++ b/web/satellite/package.json @@ -8,6 +8,7 @@ "lint-ci": "vue-cli-service lint --max-warnings 0 --no-fix && stylelint . --max-warnings 0 --no-fix", "build": "vue-cli-service build", "wasm": "chmod +x ./scripts/build-wasm.sh && ./scripts/build-wasm.sh", + "wasm-dev": "chmod +x ./scripts/build-wasm-dev.sh && ./scripts/build-wasm-dev.sh", "dev": "vue-cli-service build --mode development --watch", "test": "vue-cli-service test:unit" }, diff --git a/web/satellite/scripts/build-wasm-dev.sh b/web/satellite/scripts/build-wasm-dev.sh new file mode 100755 index 000000000..ba90d25a4 --- /dev/null +++ b/web/satellite/scripts/build-wasm-dev.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +# Copy wasm javascript to match the go version +cp "$(go env GOROOT)/misc/wasm/wasm_exec.js" ./static/wasm + +# Build wasm code +GOOS=js GOARCH=wasm go build -o ./static/wasm/access.wasm storj.io/storj/satellite/console/wasm \ No newline at end of file