Skip to content

Commit d979430

Browse files
authored
ci(benchmark): detect machine with IMDSv2 [skip ci] (#10876)
1 parent eed48d8 commit d979430

File tree

6 files changed

+40
-29
lines changed

6 files changed

+40
-29
lines changed

.github/actions/benchmark_cloud/action.yml

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ runs:
6565
working-directory: benchmark/clickbench
6666
shell: bash
6767
run: |
68-
yq -i ".date = \"$(date -u +%Y-%m-%d)\"" result.json
6968
case ${{ inputs.source }} in
7069
pr)
7170
yq -i '.system = "Databend(PR#${{ inputs.source_id }})"' result.json
@@ -77,22 +76,7 @@ runs:
7776
echo "Unspported benchmark source: ${{ inputs.source }}"
7877
exit 1
7978
esac
80-
81-
case ${{ inputs.size }} in
82-
Medium)
83-
yq -i '.cluster_size = "16"' result.json
84-
yq -i '.machine = "16×Medium"' result.json
85-
;;
86-
Large)
87-
yq -i '.cluster_size = "64"' result.json
88-
yq -i '.machine = "64×Large"' result.json
89-
;;
90-
*)
91-
echo "Unspported benchmark size: ${{ inputs.size }}"
92-
exit 1
93-
esac
94-
yq -i '.tags = ["s3"]' result.json
95-
yq -i '.comment = "commit:${{ inputs.sha }}"' result.json
79+
yq -i '.comment = "commit: ${{ inputs.sha }}"' result.json
9680
mv result.json result-${{ inputs.dataset }}-cloud-${{ inputs.size }}.json
9781
9882
- name: Upload artifact

.github/actions/benchmark_local/action.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,7 @@ runs:
5050
echo "Unspported benchmark source: ${{ inputs.source }}"
5151
exit 1
5252
esac
53-
yq -i ".date = \"$(date -u +%Y-%m-%d)\"" result.json
54-
yq -i '.machine = "c5.4xlarge"' result.json
55-
yq -i '.cluster_size = 1' result.json
56-
yq -i '.comment = "commit:${{ inputs.sha }}"' result.json
57-
yq -i '.tags = ["gp3"]' result.json
58-
yq -i '.extra.${{ inputs.source }} = "${{ inputs.source_id }}"' result.json
53+
yq -i '.comment = "commit: ${{ inputs.sha }}"' result.json
5954
mv result.json result-${{ inputs.dataset }}-local.json
6055
6156
- name: Upload artifact

benchmark/clickbench/benchmark_cloud.sh

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,25 @@ python3 --version
2929
yq --version
3030
bendsql version
3131

32+
echo "Preparing benchmark metadata..."
33+
echo '{}' >result.json
34+
yq -i ".date = \"$(date -u +%Y-%m-%d)\"" result.json
35+
yq -i '.tags = ["s3"]' result.json
36+
case ${BENCHMARK_SIZE} in
37+
Medium)
38+
yq -i '.cluster_size = "16"' result.json
39+
yq -i '.machine = "16×Medium"' result.json
40+
;;
41+
Large)
42+
yq -i '.cluster_size = "64"' result.json
43+
yq -i '.machine = "64×Large"' result.json
44+
;;
45+
*)
46+
echo "Unspported benchmark size: ${BENCHMARK_SIZE}"
47+
exit 1
48+
;;
49+
esac
50+
3251
echo "#######################################################"
3352
echo "Running benchmark for Databend Cloud with S3 storage..."
3453

@@ -44,10 +63,8 @@ bendsql cloud warehouse ls
4463
bendsql cloud warehouse create "${CLOUD_WAREHOUSE}" --size "${BENCHMARK_SIZE}" --tag "${BENCHMARK_IMAGE_TAG}"
4564
bendsql cloud warehouse ls
4665
bendsql cloud warehouse resume "${CLOUD_WAREHOUSE}" --wait
47-
4866
bendsql cloud warehouse use "${CLOUD_WAREHOUSE}"
4967

50-
echo '{}' >result.json
5168
echo "Running queries..."
5269

5370
function run_query() {

benchmark/clickbench/benchmark_local.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ echo "CREATE DATABASE ${BENCHMARK_DATASET};" | bendsql query
4747
echo "Creating table for benchmark with native storage format..."
4848
bendsql query <"${BENCHMARK_DATASET}/create_local.sql"
4949

50+
# Detect instance type with AWS metadata
51+
token=$(curl -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 60")
52+
instance_type=$(curl -H "X-aws-ec2-metadata-token: $token" http://169.254.169.254/latest/meta-data/instance-type)
53+
echo "Instance type: ${instance_type}"
54+
5055
echo "Loading data..."
5156
load_start=$(date +%s)
5257
bendsql query <"${BENCHMARK_DATASET}/load.sql"
@@ -57,7 +62,11 @@ echo "Data loaded in ${load_time}s."
5762
data_size=$(echo "select sum(data_compressed_size) from system.tables where database = '${BENCHMARK_DATASET}';" | bendsql query -f unaligned -t)
5863

5964
echo '{}' >result.json
65+
yq -i ".date = \"$(date -u +%Y-%m-%d)\"" result.json
6066
yq -i ".load_time = ${load_time} | .data_size = ${data_size} | .result = []" result.json
67+
yq -i ".machine = \"${instance_type}\"" result.json
68+
yq -i '.cluster_size = 1' result.json
69+
yq -i '.tags = ["gp3"]' result.json
6170

6271
echo "Running queries..."
6372

benchmark/clickbench/index.jinja

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,9 +304,9 @@
304304
<div class="header stick-left">
305305
<span class="nowrap themes"><span id="toggle-dark">🌚</span><span id="toggle-light">🌞</span></span>
306306
<h1>{{ title }}</h1>
307-
<a href="https://github.com/ClickHouse/ClickBench/">Other System</a> |
308-
<a href="https://repo.databend.rs/benchmark/clickbench/release/tpch.html">Release Versions Benchmark</a> |
309-
<a href="{{ url }}">Benchmark Source Detail</a>
307+
<a href="https://github.com/ClickHouse/ClickBench/">Clickbench</a> |
308+
<a href="https://repo.databend.rs/benchmark/clickbench/release/{{ dataset }}.html">Release Versions</a> |
309+
<a href="{{ url }}">Changeset Detail</a>
310310
</div>
311311

312312
<table class="selectors-container stick-left">

benchmark/clickbench/update_results.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,13 @@ def update_results(dataset, title, url):
3030
templateEnv = Environment(loader=templateLoader)
3131
template = templateEnv.get_template(TEMPLATE_FILE)
3232
logger.info("rendering result with args: %s ...", args)
33-
outputText = template.render(title=title, url=url, queries=queries, results=results)
33+
outputText = template.render(
34+
dataset=dataset,
35+
title=title,
36+
url=url,
37+
queries=queries,
38+
results=results,
39+
)
3440
with open(f"results/{dataset}.html", "w") as f:
3541
f.write(outputText)
3642

0 commit comments

Comments
 (0)