Skip to content

Commit d11512a

Browse files
authored
Merge pull request #10518 from everpcpc/feat-bench
chore(ci): fix download artifacts for benchmark
2 parents f19c983 + e969dd9 commit d11512a

File tree

5 files changed

+89
-65
lines changed

5 files changed

+89
-65
lines changed

.github/actions/benchmark_local/action.yml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,6 @@ inputs:
1919
runs:
2020
using: "composite"
2121
steps:
22-
- name: Download artifact
23-
uses: ./.github/actions/artifact_download
24-
with:
25-
profile: release
26-
sha: ${{ inputs.sha }}
27-
target: x86_64-unknown-linux-gnu
28-
29-
- name: Setup Databend Binary
30-
shell: bash
31-
run: |
32-
sudo cp ./target/release/databend-query /usr/local/bin/databend-query
33-
sudo cp ./target/release/databend-meta /usr/local/bin/databend-meta
34-
databend-query --version
35-
databend-meta --version
36-
3722
- uses: ./.github/actions/setup_bendsql
3823

3924
- name: Install script dependencies

.github/workflows/benchmark.yml

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,6 @@ on:
1515
- "**.md"
1616
- "docker/**"
1717
- ".devcontainer/**"
18-
workflow_dispatch:
19-
inputs:
20-
tag:
21-
description: The tag to run benchmark
22-
required: true
23-
type: string
2418

2519
concurrency:
2620
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
@@ -29,13 +23,10 @@ concurrency:
2923
env:
3024
BUILD_PROFILE: release
3125
RUNNER_PROVIDER: aws
32-
CARGO_INCREMENTAL: 0
33-
# Remove this env after rust 1.68 has been released.
34-
CARGO_UNSTABLE_SPARSE_REGISTRY: true
3526

3627
jobs:
3728
build_release:
38-
if: github.event_name == 'workflow_dispatch' || contains(github.event.pull_request.labels.*.name, 'ci-benchmark')
29+
if: contains(github.event.pull_request.labels.*.name, 'ci-benchmark')
3930
timeout-minutes: 30
4031
runs-on: [self-hosted, X64, Linux, perf]
4132
steps:
@@ -47,29 +38,12 @@ jobs:
4738
with:
4839
target: x86_64-unknown-linux-gnu
4940
profile: release
50-
- name: Get benchmark source
51-
run: |
52-
case ${{ github.event_name }} in
53-
pull_request)
54-
echo "BENCHMARK_SOURCE=pr" > $GITHUB_ENV
55-
echo "BENCHMARK_SOURCE_ID=${{ github.event.pull_request.number }}" >> $GITHUB_ENV
56-
;;
57-
workflow_dispatch)
58-
echo "BENCHMARK_SOURCE=release" > $GITHUB_ENV
59-
echo "BENCHMARK_SOURCE_ID=${{ github.event.inputs.tag }}" >> $GITHUB_ENV
60-
;;
61-
*)
62-
echo "Unknown event name: ${{ github.event_name }}"
63-
exit 1
64-
;;
65-
esac
6641
- name: Generate benchmark metadata
6742
run: |
6843
echo '{}' > metadata.json
6944
jq ".sha = \"${{ github.sha }}\"" <metadata.json >metadata.json.tmp && mv metadata.json.tmp metadata.json
7045
jq ".run_id = \"${{ github.run_id }}\"" <metadata.json >metadata.json.tmp && mv metadata.json.tmp metadata.json
71-
jq ".source = \"${{ env.BENCHMARK_SOURCE }}\"" <metadata.json >metadata.json.tmp && mv metadata.json.tmp metadata.json
72-
jq ".source_id = \"${{ env.BENCHMARK_SOURCE_ID }}\"" <metadata.json >metadata.json.tmp && mv metadata.json.tmp metadata.json
46+
jq ".pr_id = \"${{ github.event.pull_request.number }}\"" <metadata.json >metadata.json.tmp && mv metadata.json.tmp metadata.json
7347
- name: Upload artifact
7448
uses: actions/upload-artifact@v3
7549
with:

.github/workflows/release.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,6 @@ jobs:
7676
gh release create ${{ steps.generated-tag.outputs.tag }} --generate-notes -p
7777
env:
7878
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
79-
- name: Trigger benchmark
80-
continue-on-error: true
81-
run: |
82-
echo "Trigger benchmark for ${{ steps.generated-tag.outputs.tag }}"
83-
gh workflow run benchmark.yml -f tag=${{ steps.generated-tag.outputs.tag }}
84-
env:
85-
GH_TOKEN: ${{ secrets.DATABEND_BOT_TOKEN }}
86-
8779

8880
publish_macos:
8981
name: macos assets
@@ -521,6 +513,14 @@ jobs:
521513
asset_name: sha256sums.txt
522514
asset_content_type: text/plain
523515

516+
run_benchmark:
517+
name: run benchmark
518+
needs: [create_release, publish_linux]
519+
uses: ./.github/workflows/trusted-benchmark.yml
520+
secrets: inherit
521+
with:
522+
tag: ${{ needs.create_release.outputs.version }}
523+
524524
notify_build_result:
525525
name: notify build result
526526
runs-on: ubuntu-latest

.github/workflows/trusted-benchmark.yml

Lines changed: 77 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ on:
55
workflows: ["Benchmark"]
66
types:
77
- completed
8+
workflow_call:
9+
inputs:
10+
tag:
11+
description: The tag to run benchmark
12+
required: true
13+
type: string
814

915
permissions:
1016
id-token: write
@@ -30,11 +36,26 @@ jobs:
3036
env:
3137
GH_TOKEN: ${{ github.token }}
3238
run: |
33-
gh run download ${{ github.event.workflow_run.id }} --name benchmark-metadata
34-
echo "sha=$(jq -r '.sha' metadata.json)" >> $GITHUB_OUTPUT
35-
echo "run_id=$(jq -r '.run_id' metadata.json)" >> $GITHUB_OUTPUT
36-
echo "source=$(jq -r '.source' metadata.json)" >> $GITHUB_OUTPUT
37-
echo "source_id=$(jq -r '.source_id' metadata.json)" >> $GITHUB_OUTPUT
39+
case ${{ github.event_name }} in
40+
# pull request
41+
workflow_run)
42+
gh run download ${{ github.event.workflow_run.id }} --name benchmark-metadata
43+
echo "sha=$(jq -r '.sha' metadata.json)" >> $GITHUB_OUTPUT
44+
echo "run_id=$(jq -r '.run_id' metadata.json)" >> $GITHUB_OUTPUT
45+
echo "source=pr" >> $GITHUB_OUTPUT
46+
echo "source_id=$(jq -r '.pr_id' metadata.json)" >> $GITHUB_OUTPUT
47+
;;
48+
workflow_call)
49+
echo "sha=${{ github.sha }}" >> $GITHUB_OUTPUT
50+
echo "run_id=${{ github.run_id }}" >> $GITHUB_OUTPUT
51+
echo "source=release" >> $GITHUB_OUTPUT
52+
echo "source_id=${{ github.event.inputs.tag }}" >> $GITHUB_OUTPUT
53+
;;
54+
*)
55+
echo "Unknown event name: ${{ github.event_name }}"
56+
exit 1
57+
;;
58+
esac
3859
3960
local:
4061
needs: metadata
@@ -47,6 +68,32 @@ jobs:
4768
- tpch
4869
steps:
4970
- uses: actions/checkout@v3
71+
- name: Download artifact
72+
run: |
73+
mkdir -p ./target/release
74+
case ${{ needs.metadata.outputs.source }} in
75+
pr)
76+
aws s3 sync s3://databend-ci/release/${{ needs.metadata.outputs.sha }}/x86_64-unknown-linux-gnu/default/ \
77+
target/release/ --exclude "*" --include "databend-*" --no-progress
78+
;;
79+
release)
80+
version=${{ needs.metadata.outputs.source_id }}
81+
target=x86_64-unknown-linux-gnu
82+
wget -P distro -qc https://repo.databend.rs/databend/${version}/databend-${version}-${target}.tar.gz
83+
tar x -C ./target/release -f ./distro/databend-${version}-${target}.tar.gz --strip-components 1 bin/
84+
;;
85+
*)
86+
echo "Unknown source: ${{ needs.metadata.outputs.source }}"
87+
exit 1
88+
;;
89+
esac
90+
chmod +x ./target/release/databend-*
91+
- name: Setup Databend Binary
92+
shell: bash
93+
run: |
94+
sudo cp ./target/release/databend-* /usr/local/bin/
95+
databend-query --version
96+
databend-meta --version
5097
- uses: ./.github/actions/benchmark_local
5198
with:
5299
sha: ${{ needs.metadata.outputs.sha }}
@@ -63,17 +110,35 @@ jobs:
63110
tag: ${{ steps.prepare.outputs.tag }}
64111
steps:
65112
- uses: actions/checkout@v3
113+
- name: Download artifact
114+
run: |
115+
mkdir -p ./target/release
116+
case ${{ needs.metadata.outputs.source }} in
117+
pr)
118+
aws s3 sync s3://databend-ci/release/${{ needs.metadata.outputs.sha }}/x86_64-unknown-linux-gnu/default/ \
119+
target/release/ --exclude "*" --include "databend-*" --no-progress
120+
;;
121+
release)
122+
version=${{ needs.metadata.outputs.source_id }}
123+
target=x86_64-unknown-linux-gnu
124+
wget -P distro -qc https://repo.databend.rs/databend/${version}/databend-${version}-${target}.tar.gz
125+
tar x -C ./target/release -f ./distro/databend-${version}-${target}.tar.gz --strip-components 1 bin/
126+
;;
127+
*)
128+
echo "Unknown source: ${{ needs.metadata.outputs.source }}"
129+
exit 1
130+
;;
131+
esac
132+
chmod +x ./target/release/databend-*
133+
- name: Prepare docker build
134+
run: |
135+
mkdir -p ./distro/linux/amd64
136+
cp ./target/release/databend-* ./distro/linux/amd64
66137
- uses: ./.github/actions/setup_docker
67138
id: login
68139
with:
69140
repo: databend-query
70141
ecr_role_arn: ${{ secrets.ECR_ROLE_ARN }}
71-
- name: Download artifact
72-
uses: ./.github/actions/artifact_download
73-
with:
74-
profile: release
75-
sha: ${{ needs.metadata.outputs.sha }}
76-
target: x86_64-unknown-linux-gnu
77142
- name: Prepare for docker
78143
id: prepare
79144
run: |
@@ -91,7 +156,7 @@ jobs:
91156

92157
cloud:
93158
needs: [metadata, docker]
94-
timeout-minutes: 30
159+
timeout-minutes: 60
95160
runs-on: [self-hosted, X64, Linux, dev]
96161
steps:
97162
- uses: actions/checkout@v3

benchmark/clickbench/benchmark_cloud.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ bendsql cloud login \
3939
--org "${CLOUD_ORG}"
4040

4141
bendsql cloud warehouse ls
42-
bendsql cloud warehouse create "${CLOUD_WAREHOUSE}" --size 1 --tag "${BENCHMARK_IMAGE_TAG}"
42+
bendsql cloud warehouse create "${CLOUD_WAREHOUSE}" --size "${BENCHMARK_SIZE}" --tag "${BENCHMARK_IMAGE_TAG}"
4343
bendsql cloud warehouse ls
4444
bendsql cloud warehouse resume "${CLOUD_WAREHOUSE}" --wait
4545

@@ -104,4 +104,4 @@ while read -r query; do
104104
done <"${BENCHMARK_DATASET}/queries.sql"
105105

106106
echo "Cleaning up..."
107-
bendsql cloud warehouse delete: "${CLOUD_WAREHOUSE}"
107+
bendsql cloud warehouse delete "${CLOUD_WAREHOUSE}"

0 commit comments

Comments
 (0)