forked from databendlabs/databend
-
Notifications
You must be signed in to change notification settings - Fork 0
268 lines (257 loc) · 9.62 KB
/
reuse.benchmark.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
name: Benchmark
on:
workflow_call:
inputs:
sha:
description: Git sha of benchmark
required: true
type: string
run_id:
description: The run id of benchmark
required: true
type: string
source:
description: The source of benchmark, pr/release
required: true
type: string
source_id:
description: The source id of benchmark, pr number/release tag
required: true
type: string
version:
description: The version of databend to run
required: true
type: string
runner_provider:
description: "Self-hosted runner provider, aws or gcp"
type: string
required: true
target:
description: "The target of benchmark, local or cloud or all"
type: string
required: true
permissions:
id-token: write
pull-requests: write
contents: read
env:
BUILD_PROFILE: release
RUNNER_PROVIDER: ${{ inputs.runner_provider }}
jobs:
local:
timeout-minutes: 60
runs-on: [self-hosted, X64, Linux, 16c32g, "${{ inputs.runner_provider }}"]
strategy:
matrix:
dataset:
- internal
# - hits
fail-fast: true
max-parallel: 1
steps:
- uses: actions/checkout@v4
if: inputs.source == 'release'
with:
ref: ${{ inputs.sha }}
- uses: actions/checkout@v4
if: inputs.source == 'pr'
with:
ref: "refs/pull/${{ inputs.source_id }}/merge"
- uses: ./.github/actions/setup_bendsql
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Download artifact
uses: ./.github/actions/artifact_download
with:
sha: ${{ inputs.sha }}
target: x86_64-unknown-linux-gnu
category: udf
artifacts: meta,query
- name: Setup Databend Binary
shell: bash
run: |
sudo cp ./target/release/databend-* /usr/local/bin/
databend-query --version
databend-meta --version
- uses: ./.github/actions/benchmark_local
if: inputs.target == 'local' || inputs.target == 'all'
timeout-minutes: 30
id: benchmark
with:
sha: ${{ inputs.sha }}
run_id: ${{ inputs.run_id }}
dataset: ${{ matrix.dataset }}
source: ${{ inputs.source }}
source_id: ${{ inputs.source_id }}
load:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
if: inputs.source == 'release'
with:
ref: ${{ inputs.sha }}
- uses: actions/checkout@v4
if: inputs.source == 'pr'
with:
ref: "refs/pull/${{ inputs.source_id }}/merge"
- uses: ./.github/actions/setup_bendsql
- uses: ./.github/actions/benchmark_cloud
if: inputs.target == 'load' || inputs.target == 'all'
timeout-minutes: 120
id: benchmark
with:
sha: ${{ inputs.sha }}
run_id: ${{ inputs.run_id }}
dataset: load
source: ${{ inputs.source }}
source_id: ${{ inputs.source_id }}
size: Small
version: ${{ inputs.version }}
cloud_user: ${{ secrets.BENCHMARK_CLOUD_USER }}
cloud_password: ${{ secrets.BENCHMARK_CLOUD_PASSWORD }}
cloud_gateway: ${{ secrets.BENCHMARK_CLOUD_GATEWAY }}
- name: clean
if: always()
continue-on-error: true
env:
BENDSQL_DSN: "databend://${{ secrets.BENCHMARK_CLOUD_USER }}:${{ secrets.BENCHMARK_CLOUD_PASSWORD }}@${{ secrets.BENCHMARK_CLOUD_GATEWAY }}:443/?warehouse=default"
run: |
echo "DROP DATABASE IF EXISTS load_test_${{ inputs.run_id }};" | bendsql
echo "DROP WAREHOUSE IF EXISTS 'benchmark-${{ inputs.run_id }}';" | bendsql
cloud:
runs-on: ubuntu-latest
needs: load
strategy:
matrix:
include:
- { dataset: hits, size: Small }
- { dataset: hits, size: Large }
- { dataset: tpch, size: Small }
- { dataset: tpch, size: Large }
fail-fast: true
max-parallel: 1
steps:
- uses: actions/checkout@v4
if: inputs.source == 'release'
with:
ref: ${{ inputs.sha }}
- uses: actions/checkout@v4
if: inputs.source == 'pr'
with:
ref: "refs/pull/${{ inputs.source_id }}/merge"
- uses: ./.github/actions/setup_bendsql
- uses: ./.github/actions/benchmark_cloud
if: inputs.target == 'cloud' || inputs.target == 'all'
timeout-minutes: 20
id: benchmark
with:
sha: ${{ inputs.sha }}
run_id: ${{ inputs.run_id }}
dataset: ${{ matrix.dataset }}
source: ${{ inputs.source }}
source_id: ${{ inputs.source_id }}
size: ${{ matrix.size }}
version: ${{ inputs.version }}
cloud_user: ${{ secrets.BENCHMARK_CLOUD_USER }}
cloud_password: ${{ secrets.BENCHMARK_CLOUD_PASSWORD }}
cloud_gateway: ${{ secrets.BENCHMARK_CLOUD_GATEWAY }}
- name: clean
if: always()
continue-on-error: true
env:
BENDSQL_DSN: "databend://${{ secrets.BENCHMARK_CLOUD_USER }}:${{ secrets.BENCHMARK_CLOUD_PASSWORD }}@${{ secrets.BENCHMARK_CLOUD_GATEWAY }}:443/?warehouse=default"
run: |
echo "DROP WAREHOUSE IF EXISTS 'benchmark-${{ inputs.run_id }}';" | bendsql
comment:
needs: [local, cloud]
if: inputs.source == 'pr'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Dependencies
run: |
sudo apt-get update -yq
sudo apt-get install -yq python3-jinja2
- uses: actions/download-artifact@v4
with:
path: benchmark/clickbench/results
pattern: benchmark-*
merge-multiple: true
- name: Get Report Prefix
run: |
for result in benchmark/clickbench/results/*.json; do
dataset=$(echo $result | sed -E 's/.*result-(\w+)-.*\.json/\1/')
mkdir -p benchmark/clickbench/results/${dataset}/
mv $result benchmark/clickbench/results/${dataset}/$(basename $result)
done
echo "REPORT_S3_PREFIX=s3://benchmark/clickbench/pr/${{ inputs.source_id }}/${{ inputs.run_id }}" >> $GITHUB_ENV
- name: Upload PR clickbench result to R2
id: result
env:
AWS_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: auto
AWS_ENDPOINT_URL: ${{ secrets.R2_ENDPOINT_URL }}
working-directory: benchmark/clickbench
run: |
echo -e "## ClickBench Report\n" > /tmp/body
for p in results/*; do
dataset=$(basename $p)
aws s3 sync results/$dataset/ ${REPORT_S3_PREFIX}/ --include "*.json"
aws s3 sync "s3://benchmark/clickbench/release/${dataset}/latest/" ./results/${dataset}/ --exclude "*" --include "*.json"
./update_results.py --dataset $dataset --pr ${{ inputs.source_id }}
aws s3 cp ./results/${dataset}.html ${REPORT_S3_PREFIX}/${dataset}.html
echo "* **${dataset}**: https://benchmark.databend.com/clickbench/pr/${{ inputs.source_id }}/${{ inputs.run_id }}/${dataset}.html" >> /tmp/body
done
- name: Comment on PR
uses: everpcpc/comment-on-pr-action@v1
with:
token: ${{ github.token }}
files: /tmp/body
number: ${{ inputs.source_id }}
archive:
needs: [local, cloud]
if: inputs.source == 'release'
runs-on: ubuntu-latest
strategy:
matrix:
dataset:
- "tpch"
- "hits"
- "load"
- "internal"
steps:
- uses: actions/checkout@v4
- name: Install Dependencies
run: |
sudo apt-get update -yq
sudo apt-get install -yq python3-jinja2
- uses: actions/download-artifact@v4
with:
path: benchmark/clickbench/results
pattern: benchmark-${{ matrix.dataset }}-*
merge-multiple: true
- name: Generate report and upload to R2
working-directory: benchmark/clickbench
env:
AWS_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: auto
AWS_ENDPOINT_URL: ${{ secrets.R2_ENDPOINT_URL }}
run: |
for result in results/*.json; do
dataset=$(echo $result | sed -E 's/.*result-(\w+)-.*\.json/\1/')
mkdir -p results/${dataset}/
mv $result results/${dataset}/$(basename $result)
done
aws s3 sync s3://benchmark/clickbench/release/${{ matrix.dataset }}/$(date --date='-1 month' -u +%Y)/$(date --date='-1 month' -u +%m)/ ./results/${{ matrix.dataset }}/ --no-progress
aws s3 sync s3://benchmark/clickbench/release/${{ matrix.dataset }}/$(date -u +%Y)/$(date -u +%m)/ ./results/${{ matrix.dataset }}/ --no-progress
./update_results.py --dataset ${{ matrix.dataset }} --release ${{ inputs.source_id }}
RESULT_PREFIX="s3://benchmark/clickbench/release/${{ matrix.dataset }}/$(date -u +%Y)/$(date -u +%m)/$(date -u +%Y-%m-%d)/${{ inputs.source_id }}"
LATEST_PREFIX="s3://benchmark/clickbench/release/${{ matrix.dataset }}/latest/latest"
for file in ./results/${{ matrix.dataset }}/*.json; do
aws s3 cp $file "${RESULT_PREFIX}-$(basename $file)"
aws s3 cp $file "${LATEST_PREFIX}-$(basename $file)"
done
aws s3 cp ./results/${{ matrix.dataset }}.html s3://benchmark/clickbench/release/${{ matrix.dataset }}.html