-
Notifications
You must be signed in to change notification settings - Fork 4.2k
ARROW-17751: [Go][Benchmarking] Add Go Benchmark Script #14148
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
Changes from 23 commits
6426da4
86f4d6c
1e7c87d
8cd2523
5986de0
6a1789c
41c4188
b2aff81
b98196b
b3f56de
e541999
65e02db
4659882
b51a589
d1b37b2
cc2a3bf
0c9b436
d7806c8
023a994
9f7cedc
d23f79e
d23e513
72bcf9d
2ffda34
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -46,7 +46,7 @@ jobs: | |||||
| name: AMD64 Debian 11 Go ${{ matrix.go }} | ||||||
| runs-on: ubuntu-latest | ||||||
| if: ${{ !contains(github.event.pull_request.title, 'WIP') }} | ||||||
| timeout-minutes: 15 | ||||||
| timeout-minutes: 30 | ||||||
| strategy: | ||||||
| fail-fast: false | ||||||
| matrix: | ||||||
|
|
@@ -68,7 +68,7 @@ jobs: | |||||
| - name: Setup Python | ||||||
| uses: actions/setup-python@v4 | ||||||
| with: | ||||||
| python-version: 3.8 | ||||||
| python-version: '3.10' | ||||||
| - name: Setup Archery | ||||||
| run: pip install -e dev/archery[docker] | ||||||
| - name: Execute Docker Build | ||||||
|
|
@@ -77,6 +77,15 @@ jobs: | |||||
| if: success() && github.event_name == 'push' && github.repository == 'apache/arrow' | ||||||
| continue-on-error: true | ||||||
| run: archery docker push debian-go | ||||||
| - name: Run Benchmarks | ||||||
| if: success() && github.event_name == 'push' && github.repository == 'apache/arrow' | ||||||
| env: | ||||||
| CONBENCH_URL: https://conbench.ursa.dev | ||||||
| CONBENCH_EMAIL: ${{ secrets.CONBENCH_EMAIL }} | ||||||
| CONBENCH_PASSWORD: ${{ secrets.CONBENCH_PASS }} | ||||||
| run: | | ||||||
| pip install benchadapt@git+https://github.com/conbench/conbench.git@main#subdirectory=benchadapt/python | ||||||
| python ci/scripts/go_bench_adapt.py | ||||||
|
|
||||||
| docker_cgo: | ||||||
| name: AMD64 Debian 11 GO ${{ matrix.go }} - CGO | ||||||
|
|
@@ -183,13 +192,13 @@ jobs: | |||||
| run: ci/scripts/go_build.sh $(pwd) | ||||||
| - name: Test | ||||||
| shell: bash | ||||||
| run: ci/scripts/go_test.sh $(pwd) | ||||||
| run: ci/scripts/go_test.sh $(pwd) | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit
Suggested change
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ran trim trailing whitespace to fix that :) And yea, tested it on my fork before I removed the runs on PRs to have it only run on pushes to apache/arrow repo. |
||||||
|
|
||||||
| macos: | ||||||
| name: AMD64 macOS 11 Go ${{ matrix.go }} | ||||||
| runs-on: macos-latest | ||||||
| if: ${{ !contains(github.event.pull_request.title, 'WIP') }} | ||||||
| timeout-minutes: 15 | ||||||
| timeout-minutes: 30 | ||||||
| strategy: | ||||||
| fail-fast: false | ||||||
| matrix: | ||||||
|
|
@@ -219,6 +228,22 @@ jobs: | |||||
| - name: Test | ||||||
| shell: bash | ||||||
| run: ci/scripts/go_test.sh $(pwd) | ||||||
| - name: Setup Python | ||||||
| if: success() && github.event_name == 'push' && github.repository == 'apache/arrow' | ||||||
| uses: actions/setup-python@v4 | ||||||
| with: | ||||||
| python-version: '3.10' | ||||||
| - name: Run Benchmarks | ||||||
| if: success() && github.event_name == 'push' && github.repository == 'apache/arrow' | ||||||
| shell: bash | ||||||
| env: | ||||||
| CONBENCH_URL: 'https://conbench.ursa.dev' | ||||||
| CONBENCH_EMAIL: ${{ secrets.CONBENCH_EMAIL }} | ||||||
| CONBENCH_PASSWORD: ${{ secrets.CONBENCH_PASS }} | ||||||
| run: | | ||||||
| pip install benchadapt@git+https://github.com/conbench/conbench.git@main#subdirectory=benchadapt/python | ||||||
| python ci/scripts/go_bench_adapt.py | ||||||
|
|
||||||
|
|
||||||
| macos-cgo: | ||||||
| name: AMD64 macOS 11 Go ${{ matrix.go }} - CGO | ||||||
|
|
@@ -316,3 +341,4 @@ jobs: | |||||
| - name: Test | ||||||
| shell: bash | ||||||
| run: ci/scripts/go_test.sh $(pwd) | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| #!/usr/bin/env bash | ||
| # | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, | ||
| # software distributed under the License is distributed on an | ||
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| # KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations | ||
| # under the License. | ||
|
|
||
| # this will output the benchmarks to STDOUT but if `-json` is passed | ||
| # as the second argument, it will create a file "bench_stats.json" | ||
| # in the directory this is called from containing a json representation | ||
|
|
||
| set -ex | ||
|
|
||
| # simplistic semver comparison | ||
| verlte() { | ||
| [ "$1" = "`echo -e "$1\n$2" | sort -V | head -n1`" ] | ||
| } | ||
| verlt() { | ||
| [ "$1" = "$2" ] && return 1 || verlte $1 $2 | ||
| } | ||
|
|
||
| ver=`go env GOVERSION` | ||
|
|
||
| source_dir=${1}/go | ||
|
|
||
| export PARQUET_TEST_DATA=${1}/cpp/submodules/parquet-testing/data | ||
| pushd ${source_dir} | ||
|
|
||
| go test -bench=. -benchmem -run=^$ ./... | tee bench_stat.dat | ||
|
|
||
| if verlte "1.18" "${ver#go}"; then | ||
| go test -bench=. -benchmem -run=^$ ./arrow/compute | tee bench_stat_compute.dat | ||
| fi | ||
|
|
||
| popd | ||
|
|
||
| if [[ "$2" = "-json" ]]; then | ||
| go install go.bobheadxi.dev/gobenchdata@latest | ||
| export PATH=`go env GOPATH`/bin:$PATH | ||
| cat ${source_dir}/bench_*.dat | gobenchdata --json bench_stats.json | ||
| fi | ||
|
|
||
| rm ${source_dir}/bench_*.dat |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, | ||
| # software distributed under the License is distributed on an | ||
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| # KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations | ||
| # under the License. | ||
|
|
||
| import json | ||
| import os | ||
| import uuid | ||
| import logging | ||
| from pathlib import Path | ||
| from typing import List | ||
|
|
||
| from benchadapt import BenchmarkResult | ||
| from benchadapt.adapters import BenchmarkAdapter | ||
| from benchadapt.log import log | ||
|
|
||
| log.setLevel(logging.DEBUG) | ||
|
|
||
| ARROW_ROOT = Path(__file__).parent.parent.parent.resolve() | ||
| SCRIPTS_PATH = ARROW_ROOT / "ci" / "scripts" | ||
|
|
||
| class GoAdapter(BenchmarkAdapter): | ||
| result_file = "bench_stats.json" | ||
| command = ["bash", SCRIPTS_PATH / "go_bench.sh", ARROW_ROOT, "-json"] | ||
|
|
||
| def __init__(self, *args, **kwargs) -> None: | ||
| super().__init__(command=self.command, *args, **kwargs) | ||
|
|
||
| def _transform_results(self) -> List[BenchmarkResult]: | ||
| with open(self.result_file, "r") as f: | ||
| raw_results = json.load(f) | ||
|
|
||
| run_id = uuid.uuid4().hex | ||
| parsed_results = [] | ||
| for suite in raw_results[0]["Suites"]: | ||
| batch_id = uuid.uuid4().hex | ||
| pkg = suite["Pkg"] | ||
|
|
||
| for benchmark in suite["Benchmarks"]: | ||
| data = benchmark["Mem"]["MBPerSec"] * 1e6 | ||
| time = 1 / benchmark["NsPerOp"] * 1e9 | ||
|
|
||
| name = benchmark["Name"].removeprefix('Benchmark') | ||
| ncpu = name[name.rfind('-')+1:] | ||
| pieces = name[:-(len(ncpu)+1)].split('/') | ||
|
|
||
| parsed = BenchmarkResult( | ||
| run_id=run_id, | ||
| batch_id=batch_id, | ||
| stats={ | ||
| "data": [data], | ||
| "unit": "b/s", | ||
| "times": [time], | ||
| "time_unit": "i/s", | ||
| "iterations": benchmark["Runs"], | ||
| }, | ||
| context={ | ||
| "benchmark_language": "Go", | ||
| "goos": suite["Goos"], | ||
| "goarch": suite["Goarch"], | ||
| }, | ||
| tags={ | ||
| "pkg": pkg, | ||
| "num_cpu": ncpu, | ||
| "name": pieces[0], | ||
| "params": '/'.join(pieces[1:]), | ||
| }, | ||
| run_reason=f'commit', | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this only going to run on master? If so, this is fine; if not, it needs to be flipped from gh actions
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated to have the reason derived by checking the branch |
||
| ) | ||
| parsed.run_name = f"{parsed.run_reason}: {parsed.github['commit']}" | ||
| parsed_results.append(parsed) | ||
|
|
||
| return parsed_results | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| go_adapter = GoAdapter(result_fields_override={"info":{}}) | ||
| go_adapter() | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe try saving with "strip trailing whitespace"? Just trying to prevent future whitespace diffs