diff --git a/.github/workflows/build-protobuf.yml b/.github/workflows/build-protobuf.yml index 3a7f232578..414465abc0 100755 --- a/.github/workflows/build-protobuf.yml +++ b/.github/workflows/build-protobuf.yml @@ -18,9 +18,7 @@ jobs: container: image: vdaas/vald-ci-container:nightly steps: - - uses: actions/checkout@v1 - with: - fetch-depth: 10 + - uses: actions/checkout@v2 - name: build protobuf run: | make proto/all diff --git a/.github/workflows/chatops.yml b/.github/workflows/chatops.yml index 8cd0c70c48..858af5f337 100644 --- a/.github/workflows/chatops.yml +++ b/.github/workflows/chatops.yml @@ -95,7 +95,7 @@ jobs: env: USERNAME: ${{ steps.check_comments_changelog.outputs.COMMENTER_USERNAME }} REQUIRED_POLICY: changelog - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 if: steps.check_comments_changelog.outputs.BOOL_TRIGGERED == 'true' && steps.check_permissions.outputs.EXECUTABLE == 'true' with: fetch-depth: 0 @@ -170,7 +170,7 @@ jobs: API_URL: ${{ github.event.issue.comments_url }} BRANCH: ${{ steps.check_comments_rebase.outputs.BRANCH_NAME }} USERNAME: ${{ steps.check_comments_rebase.outputs.COMMENTER_USERNAME }} - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 if: steps.check_comments_rebase.outputs.BOOL_TRIGGERED == 'true' && steps.check_permissions.outputs.EXECUTABLE == 'true' - name: Automatic Rebase if: steps.check_comments_rebase.outputs.BOOL_TRIGGERED == 'true' && steps.check_permissions.outputs.EXECUTABLE == 'true' @@ -244,10 +244,8 @@ jobs: USERNAME: ${{ steps.check_comments_gen_test.outputs.COMMENTER_USERNAME }} PR_AUTHOR: ${{ github.event.issue.user.login }} API_URL: ${{ github.event.issue.comments_url }} - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 if: steps.check_comments_gen_test.outputs.BOOL_TRIGGERED == 'true' && steps.check_permissions.outputs.EXECUTABLE == 'true' - with: - fetch-depth: 10 - name: Generate tests and push if: steps.check_comments_gen_test.outputs.BOOL_TRIGGERED == 'true' && steps.check_permissions.outputs.EXECUTABLE == 'true' run: | @@ -350,10 +348,8 @@ jobs: GITHUB_TOKEN: ${{ secrets.DISPATCH_TOKEN }} USERNAME: ${{ steps.check_comments_format.outputs.COMMENTER_USERNAME }} API_URL: ${{ github.event.issue.comments_url }} - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 if: steps.check_comments_format.outputs.BOOL_TRIGGERED == 'true' && steps.check_permissions.outputs.EXECUTABLE == 'true' - with: - fetch-depth: 10 - name: Fetch golang version if: steps.check_comments_format.outputs.BOOL_TRIGGERED == 'true' && steps.check_permissions.outputs.EXECUTABLE == 'true' run: | diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 5d8527aa5a..098047d80e 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -23,9 +23,7 @@ jobs: image: vdaas/vald-ci-container:nightly steps: - name: Check out code. - uses: actions/checkout@v1 - with: - fetch-depth: 10 + uses: actions/checkout@v2 - name: Run coverage continue-on-error: true run: | diff --git a/.github/workflows/dockers-image-scan.yml b/.github/workflows/dockers-image-scan.yml index 6ab419d4e4..31b3974138 100644 --- a/.github/workflows/dockers-image-scan.yml +++ b/.github/workflows/dockers-image-scan.yml @@ -7,9 +7,7 @@ jobs: agent-ngt: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 - with: - fetch-depth: 2 + - uses: actions/checkout@v2 - name: Build the Docker image id: build_image run: | @@ -39,9 +37,7 @@ jobs: agent-sidecar: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 - with: - fetch-depth: 2 + - uses: actions/checkout@v2 - name: Build the Docker image id: build_image run: | @@ -71,9 +67,7 @@ jobs: discoverer-k8s: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 - with: - fetch-depth: 2 + - uses: actions/checkout@v2 - name: Build the Docker image id: build_image run: | @@ -103,9 +97,7 @@ jobs: gateway-vald: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 - with: - fetch-depth: 2 + - uses: actions/checkout@v2 - name: Build the Docker image id: build_image run: | @@ -135,9 +127,7 @@ jobs: meta-redis: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 - with: - fetch-depth: 2 + - uses: actions/checkout@v2 - name: Build the Docker image id: build_image run: | @@ -167,9 +157,7 @@ jobs: meta-cassandra: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 - with: - fetch-depth: 2 + - uses: actions/checkout@v2 - name: Build the Docker image id: build_image run: | @@ -199,9 +187,7 @@ jobs: backup-manager-mysql: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 - with: - fetch-depth: 2 + - uses: actions/checkout@v2 - name: Build the Docker image id: build_image run: | @@ -231,9 +217,7 @@ jobs: backup-manager-cassandra: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 - with: - fetch-depth: 2 + - uses: actions/checkout@v2 - name: Build the Docker image id: build_image run: | @@ -263,9 +247,7 @@ jobs: compressor: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 - with: - fetch-depth: 2 + - uses: actions/checkout@v2 - name: Build the Docker image id: build_image run: | @@ -295,9 +277,7 @@ jobs: manager-index: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 - with: - fetch-depth: 2 + - uses: actions/checkout@v2 - name: Build the Docker image id: build_image run: | @@ -327,9 +307,7 @@ jobs: operator-helm: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 - with: - fetch-depth: 2 + - uses: actions/checkout@v2 - name: Build the Docker image id: build_image run: | @@ -359,9 +337,7 @@ jobs: loadtest: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 - with: - fetch-depth: 2 + - uses: actions/checkout@v2 - name: Build the Docker image id: build_image run: | diff --git a/.github/workflows/e2e-bench-agent.yml b/.github/workflows/e2e-bench-agent.yml index a246667fcb..a844444ded 100644 --- a/.github/workflows/e2e-bench-agent.yml +++ b/.github/workflows/e2e-bench-agent.yml @@ -5,10 +5,9 @@ on: - master paths: - ".github/workflows/e2e-bench-agent.yml" - - "internal/**" - - "!internal/**/*_test.go" - - "!internal/db/**" - - "!internal/k8s/**" + - "internal/core/**" + - "internal/client/**" + - "internal/net/**" - "apis/grpc/**" - "pkg/agent/core/ngt/**" - "cmd/agent/core/ngt/**" @@ -18,10 +17,9 @@ on: pull_request: paths: - ".github/workflows/e2e-bench-agent.yml" - - "internal/**" - - "!internal/**/*_test.go" - - "!internal/db/**" - - "!internal/k8s/**" + - "internal/core/**" + - "internal/client/**" + - "internal/net/**" - "apis/grpc/**" - "pkg/agent/core/ngt/**" - "cmd/agent/core/ngt/**" @@ -37,12 +35,21 @@ jobs: image: vdaas/vald-ci-container:nightly steps: - name: Check out code. - uses: actions/checkout@v1 - with: - fetch-depth: 1 + uses: actions/checkout@v2 - name: Run grpc-sequential run: | make bench/agent/sequential/grpc + - name: Upload artifact + uses: actions/upload-artifact@v2 + with: + name: agent-sequential-grpc + path: | + ./pprof/agent/sequential/grpc.bin + ./pprof/agent/sequential/grpc.cpu.out + ./pprof/agent/sequential/grpc.mem.out + ./pprof/agent/sequential/grpc.trace.out + ./pprof/agent/sequential/grpc.cpu.svg + ./pprof/agent/sequential/grpc.mem.svg grpc-stream: name: grpc-stream @@ -51,12 +58,21 @@ jobs: image: vdaas/vald-ci-container:nightly steps: - name: Check out code. - uses: actions/checkout@v1 - with: - fetch-depth: 1 + uses: actions/checkout@v2 - name: Run grpc-stream run: | make bench/agent/stream + - name: Upload artifact + uses: actions/upload-artifact@v2 + with: + name: agent-stream + path: | + ./pprof/agent/stream.bin + ./pprof/agent/stream.cpu.out + ./pprof/agent/stream.mem.out + ./pprof/agent/stream.trace.out + ./pprof/agent/stream.cpu.svg + ./pprof/agent/stream.mem.svg rest: name: rest @@ -65,9 +81,18 @@ jobs: image: vdaas/vald-ci-container:nightly steps: - name: Check out code. - uses: actions/checkout@v1 - with: - fetch-depth: 1 + uses: actions/checkout@v2 - name: Run rest run: | make bench/agent/sequential/rest + - name: Upload artifact + uses: actions/upload-artifact@v2 + with: + name: agent-sequential-rest + path: | + ./pprof/agent/sequential/rest.bin + ./pprof/agent/sequential/rest.cpu.out + ./pprof/agent/sequential/rest.mem.out + ./pprof/agent/sequential/rest.trace.out + ./pprof/agent/sequential/rest.cpu.svg + ./pprof/agent/sequential/rest.mem.svg diff --git a/.github/workflows/e2e-deploy.yml b/.github/workflows/e2e-deploy.yml index 626b9f4f1f..4cc5362f78 100644 --- a/.github/workflows/e2e-deploy.yml +++ b/.github/workflows/e2e-deploy.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 45 steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 - name: wait for dockers run: | tag=$(cat versions/VALD_VERSION) diff --git a/.github/workflows/helm-lint.yml b/.github/workflows/helm-lint.yml index 7eb8d66fc3..6762f70d6f 100644 --- a/.github/workflows/helm-lint.yml +++ b/.github/workflows/helm-lint.yml @@ -12,9 +12,7 @@ jobs: image: vdaas/vald-ci-container:nightly steps: - name: Check out code. - uses: actions/checkout@v1 - with: - fetch-depth: 1 + uses: actions/checkout@v2 - name: Helm version run: | helm version @@ -31,9 +29,7 @@ jobs: image: vdaas/vald-ci-container:nightly steps: - name: Check out code. - uses: actions/checkout@v1 - with: - fetch-depth: 1 + uses: actions/checkout@v2 - name: Helm version run: | helm version diff --git a/.github/workflows/helm.yml b/.github/workflows/helm.yml index 9d48090408..81019dfc1e 100644 --- a/.github/workflows/helm.yml +++ b/.github/workflows/helm.yml @@ -15,9 +15,7 @@ jobs: image: vdaas/vald-ci-container:nightly steps: - name: Check out code. - uses: actions/checkout@v1 - with: - fetch-depth: 10 + uses: actions/checkout@v2 - name: Helm version run: | helm version @@ -68,9 +66,7 @@ jobs: image: vdaas/vald-ci-container:nightly steps: - name: Check out code. - uses: actions/checkout@v1 - with: - fetch-depth: 10 + uses: actions/checkout@v2 - name: Helm version run: | helm version diff --git a/.github/workflows/reviewdog-hadolint.yml b/.github/workflows/reviewdog-hadolint.yml index a41f34ab0c..c422b629f2 100644 --- a/.github/workflows/reviewdog-hadolint.yml +++ b/.github/workflows/reviewdog-hadolint.yml @@ -25,7 +25,7 @@ jobs: name: runner / hadolint runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 - name: hadolint uses: reviewdog/action-hadolint@v1 with: diff --git a/.github/workflows/reviewdog-markdown.yml b/.github/workflows/reviewdog-markdown.yml index 35f43abee0..7e19adbc10 100644 --- a/.github/workflows/reviewdog-markdown.yml +++ b/.github/workflows/reviewdog-markdown.yml @@ -26,7 +26,7 @@ jobs: name: runner / LanguageTool runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 - name: LanguageTool uses: reviewdog/action-languagetool@v1 with: diff --git a/.github/workflows/reviewdog.yml b/.github/workflows/reviewdog.yml index cff231d2f2..7ade709840 100755 --- a/.github/workflows/reviewdog.yml +++ b/.github/workflows/reviewdog.yml @@ -27,7 +27,7 @@ jobs: container: image: vdaas/vald-ci-container:nightly steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 - name: go build run: | go build ./... diff --git a/.github/workflows/semver.yml b/.github/workflows/semver.yml index 57e9698096..3c57c3c75f 100644 --- a/.github/workflows/semver.yml +++ b/.github/workflows/semver.yml @@ -12,7 +12,7 @@ jobs: image: vdaas/vald-ci-container:nightly steps: - name: Check out code. - uses: actions/checkout@v1 + uses: actions/checkout@v2 with: fetch-depth: 0 - name: Get latest gitwerk diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c14c268c77..60afe7ab01 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,9 +27,7 @@ jobs: image: vdaas/vald-ci-container:nightly steps: - name: Check out code. - uses: actions/checkout@v1 - with: - fetch-depth: 10 + uses: actions/checkout@v2 - name: Run tests for cmd packages / tparse run: | make test/cmd/tparse | tee tparse.txt || cat tparse.txt @@ -43,9 +41,7 @@ jobs: image: vdaas/vald-ci-container:nightly steps: - name: Check out code. - uses: actions/checkout@v1 - with: - fetch-depth: 1 + uses: actions/checkout@v2 - name: Run tests for internal packages / tparse run: | make test/internal/tparse | tee tparse.txt || cat tparse.txt @@ -59,9 +55,7 @@ jobs: image: vdaas/vald-ci-container:nightly steps: - name: Check out code. - uses: actions/checkout@v1 - with: - fetch-depth: 1 + uses: actions/checkout@v2 - name: Run tests for pkg packages / tparse run: | make test/pkg/tparse | tee tparse.txt || cat tparse.txt diff --git a/.github/workflows/update_pull_request_and_issue_template.yml b/.github/workflows/update_pull_request_and_issue_template.yml index db7f6e13e2..c43512a3d8 100644 --- a/.github/workflows/update_pull_request_and_issue_template.yml +++ b/.github/workflows/update_pull_request_and_issue_template.yml @@ -13,9 +13,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out code. - uses: actions/checkout@v1 - with: - fetch-depth: 10 + uses: actions/checkout@v2 - name: Push to master run: | TIMESTAMP=$(date +%Y%m%d_%H%M%S_%3N) diff --git a/Makefile.d/bench.mk b/Makefile.d/bench.mk index 5a2838b378..a8f98cbf90 100644 --- a/Makefile.d/bench.mk +++ b/Makefile.d/bench.mk @@ -85,6 +85,22 @@ bench/datasets/large/deep1b: \ $(DEEP1B_QUERY_FILE) \ $(DEEP1B_GROUNDTRUTH_FILE) +pprof/%.cpu.svg: \ + pprof/%.bin + go tool pprof \ + --svg \ + $< \ + $(patsubst %.svg,%.out,$@) \ + > $@ + +pprof/%.mem.svg: \ + pprof/%.bin + go tool pprof \ + --svg \ + $< \ + $(patsubst %.svg,%.out,$@) \ + > $@ + .PHONY: bench ## run all benchmarks bench: \ @@ -103,41 +119,93 @@ bench/core: \ ## run benchmark for NGT core bench/core/ngt: \ bench/core/ngt/sequential \ - bench/core/ngt/parallel + bench/core/ngt/parallel .PHONY: bench/core/ngt/sequential ## run benchmark for NGT core sequential methods -bench/core/ngt/sequential: - $(call bench-pprof,pprof/core/ngt,core,NGTSequential,sequential,\ - ./hack/benchmark/core/ngt/ngt_bench_test.go \ - -dataset=$(DATASET_ARGS)) +bench/core/ngt/sequential: \ + pprof/core/ngt/sequential.cpu.svg \ + pprof/core/ngt/sequential.mem.svg +pprof/core/ngt/sequential.bin: \ + hack/benchmark/core/ngt/ngt_bench_test.go + mkdir -p $(dir $@) + go test \ + -count=1 \ + -timeout=1h \ + -bench=NGTSequential \ + -benchmem \ + -o $@ \ + -cpuprofile $(patsubst %.bin,%.cpu.out,$@) \ + -memprofile $(patsubst %.bin,%.mem.out,$@) \ + -trace $(patsubst %.bin,%.trace.out,$@) \ + $< \ + -dataset=$(DATASET_ARGS) .PHONY: bench/core/ngt/parallel ## run benchmark for NGT core parallel methods -bench/core/ngt/parallel: - $(call bench-pprof,pprof/core/ngt,core,NGTParallel,parallel,\ - ./hack/benchmark/core/ngt/ngt_bench_test.go \ - -dataset=$(DATASET_ARGS)) +bench/core/ngt/parallel: \ + pprof/core/ngt/parallel.cpu.svg \ + pprof/core/ngt/parallel.mem.svg +pprof/core/ngt/parallel.bin: \ + hack/benchmark/core/ngt/ngt_bench_test.go + mkdir -p $(dir $@) + go test \ + -count=1 \ + -timeout=1h \ + -bench=NGTParallel \ + -benchmem \ + -o $@ \ + -cpuprofile $(patsubst %.bin,%.cpu.out,$@) \ + -memprofile $(patsubst %.bin,%.mem.out,$@) \ + -trace $(patsubst %.bin,%.trace.out,$@) \ + $< \ + -dataset=$(DATASET_ARGS) .PHONY: bench/core/gongt ## run benchmark for gongt core bench/core/gongt: \ bench/core/gongt/sequential \ - bench/core/gongt/parallel + bench/core/gongt/parallel .PHONY: bench/core/gongt/sequential ## run benchmark for gongt core sequential methods -bench/core/gongt/sequential: - $(call bench-pprof,pprof/core/gongt,core,GoNGTSequential,sequential,\ - ./hack/benchmark/core/gongt/gongt_bench_test.go \ - -dataset=$(DATASET_ARGS)) +bench/core/gongt/sequential: \ + pprof/core/gongt/sequential.cpu.svg \ + pprof/core/gongt/sequential.mem.svg +pprof/core/gongt/sequential.bin: \ + hack/benchmark/core/gongt/gongt_bench_test.go + mkdir -p $(dir $@) + go test \ + -count=1 \ + -timeout=1h \ + -bench=GoNGTSequential \ + -benchmem \ + -o $@ \ + -cpuprofile $(patsubst %.bin,%.cpu.out,$@) \ + -memprofile $(patsubst %.bin,%.mem.out,$@) \ + -trace $(patsubst %.bin,%.trace.out,$@) \ + $< \ + -dataset=$(DATASET_ARGS) .PHONY: bench/core/gongt/parallel ## run benchmark for gongt core parallel methods -bench/core/gongt/parallel: - $(call bench-pprof,pprof/core/gongt,core,GoNGTParallel,parallel,\ - ./hack/benchmark/core/gongt/gongt_bench_test.go \ - -dataset=$(DATASET_ARGS)) +bench/core/gongt/parallel: \ + pprof/core/gongt/parallel.cpu.svg \ + pprof/core/gongt/parallel.mem.svg +pprof/core/gongt/parallel.bin: \ + hack/benchmark/core/gongt/gongt_bench_test.go + mkdir -p $(dir $@) + go test \ + -count=1 \ + -timeout=1h \ + -bench=GoNGTParallel \ + -benchmem \ + -o $@ \ + -cpuprofile $(patsubst %.bin,%.cpu.out,$@) \ + -memprofile $(patsubst %.bin,%.mem.out,$@) \ + -trace $(patsubst %.bin,%.trace.out,$@) \ + $< \ + -dataset=$(DATASET_ARGS) .PHONY: bench/agent ## run benchmarks for vald agent @@ -149,26 +217,65 @@ bench/agent: \ .PHONY: bench/agent/stream ## run benchmark for agent gRPC stream bench/agent/stream: \ + pprof/agent/stream.cpu.svg \ + pprof/agent/stream.mem.svg +pprof/agent/stream.bin: \ + hack/benchmark/e2e/agent/core/ngt/ngt_bench_test.go \ ngt/install - $(call bench-pprof,pprof/agent/core/ngt,agent,gRPC_Stream,stream,\ - ./hack/benchmark/e2e/agent/core/ngt/ngt_bench_test.go \ - -dataset=$(DATASET_ARGS)) + mkdir -p $(dir $@) + go test \ + -count=1 \ + -timeout=1h \ + -bench=gRPC_Stream \ + -benchmem \ + -o $@ \ + -cpuprofile $(patsubst %.bin,%.cpu.out,$@) \ + -memprofile $(patsubst %.bin,%.mem.out,$@) \ + -trace $(patsubst %.bin,%.trace.out,$@) \ + $< \ + -dataset=$(DATASET_ARGS) .PHONY: bench/agent/sequential/grpc ## run benchmark for agent gRPC sequential bench/agent/sequential/grpc: \ + pprof/agent/sequential/grpc.cpu.svg \ + pprof/agent/sequential/grpc.mem.svg +pprof/agent/sequential/grpc.bin: \ + hack/benchmark/e2e/agent/core/ngt/ngt_bench_test.go \ ngt/install - $(call bench-pprof,pprof/agent/core/ngt,agent,gRPC_Sequential,sequential-grpc,\ - ./hack/benchmark/e2e/agent/core/ngt/ngt_bench_test.go \ - -dataset=$(DATASET_ARGS)) + mkdir -p $(dir $@) + go test \ + -count=1 \ + -timeout=1h \ + -bench=gRPC_Sequential \ + -benchmem \ + -o $@ \ + -cpuprofile $(patsubst %.bin,%.cpu.out,$@) \ + -memprofile $(patsubst %.bin,%.mem.out,$@) \ + -trace $(patsubst %.bin,%.trace.out,$@) \ + $< \ + -dataset=$(DATASET_ARGS) .PHONY: bench/agent/sequential/rest ## run benchmark for agent REST bench/agent/sequential/rest: \ + pprof/agent/sequential/rest.cpu.svg \ + pprof/agent/sequential/rest.mem.svg +pprof/agent/sequential/rest.bin: \ + hack/benchmark/e2e/agent/core/ngt/ngt_bench_test.go \ ngt/install - $(call bench-pprof,pprof/agent/core/ngt,agent,REST_Sequential,sequential-rest,\ - ./hack/benchmark/e2e/agent/core/ngt/ngt_bench_test.go \ - -dataset=$(DATASET_ARGS)) + mkdir -p $(dir $@) + go test \ + -count=1 \ + -timeout=1h \ + -bench=REST_Sequential \ + -benchmem \ + -o $@ \ + -cpuprofile $(patsubst %.bin,%.cpu.out,$@) \ + -memprofile $(patsubst %.bin,%.mem.out,$@) \ + -trace $(patsubst %.bin,%.trace.out,$@) \ + $< \ + -dataset=$(DATASET_ARGS) .PHONY: bench/ngtd ## run benchmarks for NGTD @@ -180,26 +287,65 @@ bench/ngtd: \ .PHONY: bench/ngtd/stream ## run benchmark for NGTD gRPC stream bench/ngtd/stream: \ + pprof/ngtd/stream.cpu.svg \ + pprof/ngtd/stream.mem.svg +pprof/ngtd/stream.bin: \ + hack/benchmark/e2e/external/ngtd/ngtd_bench_test.go \ ngt/install - $(call bench-pprof,pprof/external/ngtd,ngtd,gRPC_Stream,stream,\ - ./hack/benchmark/e2e/external/ngtd/ngtd_bench_test.go \ - -dataset=$(DATASET_ARGS)) + mkdir -p $(dir $@) + go test \ + -count=1 \ + -timeout=1h \ + -bench=gRPC_Stream \ + -benchmem \ + -o $@ \ + -cpuprofile $(patsubst %.bin,%.cpu.out,$@) \ + -memprofile $(patsubst %.bin,%.mem.out,$@) \ + -trace $(patsubst %.bin,%.trace.out,$@) \ + $< \ + -dataset=$(DATASET_ARGS) .PHONY: bench/ngtd/sequential/grpc ## run benchmark for NGTD gRPC sequential bench/ngtd/sequential/grpc: \ + pprof/ngtd/sequential/grpc.cpu.svg \ + pprof/ngtd/sequential/grpc.mem.svg +pprof/ngtd/sequential/grpc.bin: \ + hack/benchmark/e2e/external/ngtd/ngtd_bench_test.go \ ngt/install - $(call bench-pprof,pprof/external/ngtd,ngtd,gRPC_Sequential,sequential-grpc,\ - ./hack/benchmark/e2e/external/ngtd/ngtd_bench_test.go \ - -dataset=$(DATASET_ARGS)) + mkdir -p $(dir $@) + go test \ + -count=1 \ + -timeout=1h \ + -bench=gRPC_Sequential \ + -benchmem \ + -o $@ \ + -cpuprofile $(patsubst %.bin,%.cpu.out,$@) \ + -memprofile $(patsubst %.bin,%.mem.out,$@) \ + -trace $(patsubst %.bin,%.trace.out,$@) \ + $< \ + -dataset=$(DATASET_ARGS) .PHONY: bench/ngtd/sequential/rest ## run benchmark for NGTD REST stream bench/ngtd/sequential/rest: \ + pprof/ngtd/sequential/rest.cpu.svg \ + pprof/ngtd/sequential/rest.mem.svg +pprof/ngtd/sequential/rest.bin: \ + hack/benchmark/e2e/external/ngtd/ngtd_bench_test.go \ ngt/install - $(call bench-pprof,pprof/external/ngtd,ngtd,REST_Sequential,sequential-rest,\ - ./hack/benchmark/e2e/external/ngtd/ngtd_bench_test.go \ - -dataset=$(DATASET_ARGS)) + mkdir -p $(dir $@) + go test \ + -count=1 \ + -timeout=1h \ + -bench=REST_Sequential \ + -benchmem \ + -o $@ \ + -cpuprofile $(patsubst %.bin,%.cpu.out,$@) \ + -memprofile $(patsubst %.bin,%.mem.out,$@) \ + -trace $(patsubst %.bin,%.trace.out,$@) \ + $< \ + -dataset=$(DATASET_ARGS) .PHONY: bench/gateway ## run benchmarks for gateway @@ -209,10 +355,23 @@ bench/gateway: \ .PHONY: bench/gateway/sequential ## run benchmark for gateway sequential bench/gateway/sequential: \ + pprof/gateway/sequential.cpu.svg \ + pprof/gateway/sequential.mem.svg +pprof/gateway/sequential.bin: \ + hack/benchmark/e2e/gateway/vald/vald_bench_test.go \ ngt/install - $(call bench-pprof,pprof/gateway/vald,vald,Sequential,sequential,\ - ./hack/benchmark/e2e/gateway/vald/vald_bench_test.go \ - -dataset=$(DATASET_ARGS) -address=$(ADDRESS_ARGS)) + mkdir -p $(dir $@) + go test \ + -count=1 \ + -timeout=1h \ + -bench=Sequential \ + -benchmem \ + -o $@ \ + -cpuprofile $(patsubst %.bin,%.cpu.out,$@) \ + -memprofile $(patsubst %.bin,%.mem.out,$@) \ + -trace $(patsubst %.bin,%.trace.out,$@) \ + $< \ + -dataset=$(DATASET_ARGS) .PHONY: profile ## execute profile @@ -226,27 +385,27 @@ profile: \ .PHONY: profile/agent/stream profile/agent/stream: - $(call profile-web,pprof/agent/core/ngt,agent,stream,":6061",":6062",":6063") + $(call profile-web,pprof/agent/stream) .PHONY: profile/agent/sequential/grpc profile/agent/sequential/grpc: - $(call profile-web,pprof/agent/core/ngt,agent,sequential-grpc,":6061",":6062",":6063") + $(call profile-web,pprof/agent/sequential/grpc) .PHONY: profile/agent/sequential/rest profile/agent/sequential/rest: - $(call profile-web,pprof/agent/core/ngt,agent,sequential-rest,":6061",":6062",":6063") + $(call profile-web,pprof/agent/sequential/rest) .PHONY: profile/ngtd/stream profile/ngtd/stream: - $(call profile-web,pprof/external/ngtd,ngtd,stream,":6061",":6062",":6063") + $(call profile-web,pprof/ngtd/stream) .PHONY: profile/ngtd/sequential/grpc profile/ngtd/sequential/grpc: - $(call profile-web,pprof/external/ngtd,ngtd,sequential-grpc,":6061",":6062",":6063") + $(call profile-web,pprof/ngtd/sequential/grpc) .PHONY: profile/ngtd/sequential/rest profile/ngtd/sequential/rest: - $(call profile-web,pprof/external/ngtd,ngtd,sequential-rest,":6061",":6062",":6063") + $(call profile-web,pprof/ngtd/sequential/rest) .PHONY: metrics ## calculate all metrics diff --git a/Makefile.d/functions.mk b/Makefile.d/functions.mk index abddc0ae5a..e82b69c956 100644 --- a/Makefile.d/functions.mk +++ b/Makefile.d/functions.mk @@ -39,40 +39,15 @@ define protoc-gen $1 endef -define bench-pprof - rm -rf $1 - mkdir -p $1 - @$(call green, "starting $4 $2 benchmark") - go test -count=1 \ - -timeout=1h \ - -bench=$3 \ - -benchmem \ - -o $1/$2.bin \ - -cpuprofile $1/cpu-$4.out \ - -memprofile $1/mem-$4.out \ - -trace $1/trace-$4.out \ - $5 \ - | tee $1/result-$4.out - go tool pprof --svg \ - $1/$2.bin \ - $1/cpu-$4.out \ - > $1/cpu-$4.svg - go tool pprof --svg \ - $1/$2.bin \ - $1/mem-$4.out \ - > $1/mem-$4.svg -endef - define profile-web - @$(call green, "starting $3 $2 profiler") - go tool pprof -http=$4 \ - $1/$2.bin \ - $1/cpu-$3.out & - go tool pprof -http=$5 \ - $1/$2.bin \ - $1/mem-$3.out & - go tool trace -http=$6 \ - $1/trace-$3.out + go tool pprof -http=":6061" \ + $1.bin \ + $1.cpu.out & + go tool pprof -http=":6062" \ + $1.bin \ + $1.mem.out & + go tool trace -http=":6063" \ + $1.trace.out endef define go-lint diff --git a/hack/benchmark/e2e/agent/core/ngt/ngt_bench_test.go b/hack/benchmark/e2e/agent/core/ngt/ngt_bench_test.go index 9c7347487b..f59c70dc2b 100644 --- a/hack/benchmark/e2e/agent/core/ngt/ngt_bench_test.go +++ b/hack/benchmark/e2e/agent/core/ngt/ngt_bench_test.go @@ -56,7 +56,7 @@ func BenchmarkAgentNGT_REST_Sequential(b *testing.B) { e2e.WithName(name), e2e.WithServerStarter(func(ctx context.Context, tb testing.TB, d assets.Dataset) func() { return ngt.New( - ngt.WithDimentaion(d.Dimension()), + ngt.WithDimension(d.Dimension()), ngt.WithDistanceType(d.DistanceType()), ngt.WithObjectType(d.ObjectType()), ).Run(ctx, tb) @@ -87,7 +87,7 @@ func BenchmarkAgentNGT_gRPC_Sequential(b *testing.B) { e2e.WithName(name), e2e.WithServerStarter(func(ctx context.Context, tb testing.TB, d assets.Dataset) func() { return ngt.New( - ngt.WithDimentaion(d.Dimension()), + ngt.WithDimension(d.Dimension()), ngt.WithDistanceType(d.DistanceType()), ngt.WithObjectType(d.ObjectType()), ).Run(ctx, tb) @@ -118,7 +118,7 @@ func BenchmarkAgentNGT_gRPC_Stream(b *testing.B) { e2e.WithName(name), e2e.WithServerStarter(func(ctx context.Context, tb testing.TB, d assets.Dataset) func() { return ngt.New( - ngt.WithDimentaion(d.Dimension()), + ngt.WithDimension(d.Dimension()), ngt.WithDistanceType(d.DistanceType()), ngt.WithObjectType(d.ObjectType()), ).Run(ctx, tb) diff --git a/hack/benchmark/e2e/external/ngtd/ngtd_bench_test.go b/hack/benchmark/e2e/external/ngtd/ngtd_bench_test.go index 03e76d03a0..4e675d3e30 100644 --- a/hack/benchmark/e2e/external/ngtd/ngtd_bench_test.go +++ b/hack/benchmark/e2e/external/ngtd/ngtd_bench_test.go @@ -58,7 +58,7 @@ func BenchmarkNGTD_REST_Sequential(b *testing.B) { e2e.WithName(name), e2e.WithServerStarter(func(ctx context.Context, tb testing.TB, d assets.Dataset) func() { return ngtd.New( - ngtd.WithDimentaion(d.Dimension()), + ngtd.WithDimension(d.Dimension()), ).Run(ctx, tb) }), e2e.WithClient(client), @@ -87,7 +87,7 @@ func BenchmarkNGTD_gRPC_Sequential(b *testing.B) { e2e.WithName(name), e2e.WithServerStarter(func(ctx context.Context, tb testing.TB, d assets.Dataset) func() { return ngtd.New( - ngtd.WithDimentaion(d.Dimension()), + ngtd.WithDimension(d.Dimension()), ngtd.WithServerType(ngtd.ServerType(ngtd.GRPC)), ).Run(ctx, tb) }), @@ -117,7 +117,7 @@ func BenchmarkNGTD_gRPC_Stream(b *testing.B) { e2e.WithName(name), e2e.WithServerStarter(func(ctx context.Context, tb testing.TB, d assets.Dataset) func() { return ngtd.New( - ngtd.WithDimentaion(d.Dimension()), + ngtd.WithDimension(d.Dimension()), ngtd.WithServerType(ngtd.ServerType(ngtd.GRPC)), ).Run(ctx, tb) }), diff --git a/hack/benchmark/internal/starter/agent/core/ngt/option.go b/hack/benchmark/internal/starter/agent/core/ngt/option.go index defe1319ff..00049b85b2 100644 --- a/hack/benchmark/internal/starter/agent/core/ngt/option.go +++ b/hack/benchmark/internal/starter/agent/core/ngt/option.go @@ -94,7 +94,7 @@ func WithConfig(cfg *config.Data) Option { } } -func WithDimentaion(d int) Option { +func WithDimension(d int) Option { return func(s *server) { if s.cfg != nil && s.cfg.NGT != nil { if d > 0 { diff --git a/hack/benchmark/internal/starter/agent/core/ngt/option_test.go b/hack/benchmark/internal/starter/agent/core/ngt/option_test.go index 60f73dc8b1..49ed740aa8 100644 --- a/hack/benchmark/internal/starter/agent/core/ngt/option_test.go +++ b/hack/benchmark/internal/starter/agent/core/ngt/option_test.go @@ -138,7 +138,7 @@ func TestWithConfig(t *testing.T) { } } -func TestWithDimentaion(t *testing.T) { +func TestWithDimension(t *testing.T) { type T = interface{} type args struct { d int @@ -228,7 +228,7 @@ func TestWithDimentaion(t *testing.T) { test.checkFunc = defaultCheckFunc } - got := WithDimentaion(test.args.d) + got := WithDimension(test.args.d) obj := new(T) if err := test.checkFunc(test.want, obj, got(obj)); err != nil { tt.Errorf("error = %v", err) @@ -240,7 +240,7 @@ func TestWithDimentaion(t *testing.T) { if test.checkFunc == nil { test.checkFunc = defaultCheckFunc } - got := WithDimentaion(test.args.d) + got := WithDimension(test.args.d) obj := new(T) got(obj) if err := test.checkFunc(tt.want, obj); err != nil { diff --git a/hack/benchmark/internal/starter/external/ngtd/option.go b/hack/benchmark/internal/starter/external/ngtd/option.go index 4f1f1c3d04..9ac534b46b 100644 --- a/hack/benchmark/internal/starter/external/ngtd/option.go +++ b/hack/benchmark/internal/starter/external/ngtd/option.go @@ -21,14 +21,14 @@ type Option func(*server) var ( defaultOptions = []Option{ - WithDimentaion(128), + WithDimension(128), WithIndexDir("/tmp/ngtd/"), WithServerType(HTTP), WithPort(8200), } ) -func WithDimentaion(dim int) Option { +func WithDimension(dim int) Option { return func(n *server) { if dim > 0 { n.dim = dim diff --git a/hack/benchmark/internal/starter/external/ngtd/option_test.go b/hack/benchmark/internal/starter/external/ngtd/option_test.go index 0278dd857d..25b5b6a560 100644 --- a/hack/benchmark/internal/starter/external/ngtd/option_test.go +++ b/hack/benchmark/internal/starter/external/ngtd/option_test.go @@ -23,7 +23,7 @@ import ( "go.uber.org/goleak" ) -func TestWithDimentaion(t *testing.T) { +func TestWithDimension(t *testing.T) { type T = interface{} type args struct { dim int @@ -113,7 +113,7 @@ func TestWithDimentaion(t *testing.T) { test.checkFunc = defaultCheckFunc } - got := WithDimentaion(test.args.dim) + got := WithDimension(test.args.dim) obj := new(T) if err := test.checkFunc(test.want, obj, got(obj)); err != nil { tt.Errorf("error = %v", err) @@ -125,7 +125,7 @@ func TestWithDimentaion(t *testing.T) { if test.checkFunc == nil { test.checkFunc = defaultCheckFunc } - got := WithDimentaion(test.args.dim) + got := WithDimension(test.args.dim) obj := new(T) got(obj) if err := test.checkFunc(tt.want, obj); err != nil {