Skip to content

Commit 7adfa0e

Browse files
Refactor clickhouse-cloud to use the common script interface
Splits clickhouse-cloud/benchmark.sh into per-step scripts (install, start, stop, check, load, query, data-size) and exec's lib/benchmark-common.sh, matching chyt/clickhouse-web. This gives clickhouse-cloud the concurrent QPS / error-ratio measurement for free, and the parsing in collect-results.sh is updated for the new "Load time:" / "Data size:" / "Concurrent QPS:" log shape (also emitting concurrent_qps and concurrent_error_ratio in the result JSON). start and stop are no-ops since the cloud service is provisioned outside the runner by cloud-api.sh. To avoid the 60 s wait_stopped poll firing on every cold cycle (43 queries x 60 s ~= 43 min of dead time, plus the same again before the QPS window), lib/benchmark-common.sh now honors a new BENCH_MANAGED=yes opt-in. When set, the cold cycle collapses to a single ./check — local OS page-cache flushes and stop/start are meaningless for a SaaS engine anyway. chyt also opts in.
1 parent 2583b41 commit 7adfa0e

12 files changed

Lines changed: 107 additions & 66 deletions

File tree

chyt/benchmark.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ export YT_USE_HOSTS=0
55
export CHYT_ALIAS="${CHYT_ALIAS:-*ch_public}"
66
export BENCH_DOWNLOAD_SCRIPT=""
77
export BENCH_DURABLE=yes
8+
export BENCH_MANAGED=yes
89
exec ../lib/benchmark-common.sh

clickhouse-cloud/benchmark.sh

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,8 @@
1-
#!/bin/bash -e
2-
3-
# Go to https://clickhouse.cloud/ and create a service.
4-
# To get results for various scale, go to "Actions / Advanced Scaling" and turn the slider of the minimum scale to the right.
5-
# The number of threads is "SELECT value FROM system.settings WHERE name = 'max_threads'".
6-
7-
# Load the data
8-
9-
# export FQDN=...
10-
# export PASSWORD=...
11-
12-
clickhouse-client --host "$FQDN" --password "$PASSWORD" --secure < create.sql
13-
14-
MAX_INSERT_THREADS=$(clickhouse-client --host "$FQDN" --password "$PASSWORD" --secure --query "SELECT intDiv(getSetting('max_threads'), 4)")
15-
16-
clickhouse-client --host "$FQDN" --password "$PASSWORD" --secure --time --enable-parallel-replicas 1 --max-insert-threads $MAX_INSERT_THREADS --query "
17-
INSERT INTO hits SELECT * FROM url('https://datasets.clickhouse.com/hits_compatible/athena_partitioned/hits_{0..99}.parquet')
18-
"
19-
20-
# 343.455
21-
22-
# Run the queries
23-
24-
./run.sh
25-
26-
clickhouse-client --host "$FQDN" --password "$PASSWORD" --secure --query "SELECT total_bytes FROM system.tables WHERE name = 'hits' AND database = 'default'"
1+
#!/bin/bash
2+
# Thin shim — actual flow is in lib/benchmark-common.sh.
3+
# Data is loaded into a managed remote service provisioned by cloud-api.sh;
4+
# the local runner only needs clickhouse-client.
5+
export BENCH_DOWNLOAD_SCRIPT=""
6+
export BENCH_DURABLE=yes
7+
export BENCH_MANAGED=yes
8+
exec ../lib/benchmark-common.sh

clickhouse-cloud/check

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
set -e
3+
4+
clickhouse-client --host "$FQDN" --password "$PASSWORD" --secure --query "SELECT 1" >/dev/null

clickhouse-cloud/collect-results.sh

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,13 @@ do
1515
REPLICAS=$(echo "$f" | sed -r -e 's!'$REGEXP'!\3!')
1616
MEMORY=$(echo "$f" | sed -r -e 's!'$REGEXP'!\4!')
1717

18-
LOAD_TIME=$(head -n1 "$f" | tr -d "\n")
19-
DATA_SIZE=$(tail -n1 "$f" | tr -d "\n")
20-
RESULT_BODY=$(grep -F "[" "$f" | head -c-2)
18+
# benchmark-common.sh emits "Load time:", "Data size:", "Concurrent QPS:"
19+
# and "Concurrent error ratio:" lines, plus one "[t1,t2,t3]," per query.
20+
LOAD_TIME=$(grep -E '^Load time:' "$f" | tail -n1 | awk '{print $3}')
21+
DATA_SIZE=$(grep -E '^Data size:' "$f" | tail -n1 | awk '{print $3}')
22+
CONCURRENT_QPS=$(grep -E '^Concurrent QPS:' "$f" | tail -n1 | awk '{print $3}')
23+
CONCURRENT_ERROR_RATIO=$(grep -E '^Concurrent error ratio:' "$f" | tail -n1 | awk '{print $4}')
24+
RESULT_BODY=$(grep -E '^\[' "$f" | head -c-2)
2125

2226
# Skip when the raw result file is incomplete — load time / data size must
2327
# be plain numbers and the result body must be non-empty. Otherwise the
@@ -29,6 +33,11 @@ do
2933
continue
3034
fi
3135

36+
# QPS fields are optional — older runs predate them. When missing or
37+
# null, emit JSON null so the website code can treat them uniformly.
38+
[[ "$CONCURRENT_QPS" =~ ^[0-9]+(\.[0-9]+)?$ ]] || CONCURRENT_QPS=null
39+
[[ "$CONCURRENT_ERROR_RATIO" =~ ^[0-9]+(\.[0-9]+)?$ ]] || CONCURRENT_ERROR_RATIO=null
40+
3241
OUT="results/$YYYYMMDD/${PROVIDER}.${REPLICAS}.${MEMORY}.json"
3342
echo '
3443
{
@@ -45,6 +54,8 @@ do
4554
4655
"load_time": '$LOAD_TIME',
4756
"data_size": '$DATA_SIZE',
57+
"concurrent_qps": '$CONCURRENT_QPS',
58+
"concurrent_error_ratio": '$CONCURRENT_ERROR_RATIO',
4859
4960
"result": [
5061
'"$RESULT_BODY"'

clickhouse-cloud/data-size

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
set -e
3+
4+
clickhouse-client --host "$FQDN" --password "$PASSWORD" --secure --query "SELECT total_bytes FROM system.tables WHERE name = 'hits' AND database = 'default'"

clickhouse-cloud/install

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# clickhouse-cloud runs against a managed remote service; only the
5+
# clickhouse-client binary is required locally. cloud-api.sh already
6+
# enforces this prerequisite before invoking benchmark.sh, so this is
7+
# usually a no-op — kept as a safety net for direct ./benchmark.sh runs.
8+
if [ ! -x /usr/bin/clickhouse ]; then
9+
curl https://clickhouse.com/ | sh
10+
sudo ./clickhouse install --noninteractive
11+
fi

clickhouse-cloud/load

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
set -e
3+
4+
clickhouse-client --host "$FQDN" --password "$PASSWORD" --secure < create.sql
5+
6+
MAX_INSERT_THREADS=$(clickhouse-client --host "$FQDN" --password "$PASSWORD" --secure --query "SELECT intDiv(getSetting('max_threads'), 4)")
7+
8+
clickhouse-client --host "$FQDN" --password "$PASSWORD" --secure --enable-parallel-replicas 1 --max-insert-threads "$MAX_INSERT_THREADS" --query "
9+
INSERT INTO hits SELECT * FROM url('https://datasets.clickhouse.com/hits_compatible/athena_partitioned/hits_{0..99}.parquet')
10+
"

clickhouse-cloud/query

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
# Reads a SQL query from stdin, runs it against the managed cloud service.
3+
# Stdout: query result. Stderr: query runtime in fractional seconds on the
4+
# last line (from --time). Exit non-zero on error.
5+
set -e
6+
7+
clickhouse-client --host "$FQDN" --password "$PASSWORD" --secure --time --format Null

clickhouse-cloud/run.sh

Lines changed: 0 additions & 18 deletions
This file was deleted.

clickhouse-cloud/start

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
# clickhouse-cloud runs against a managed remote service provisioned by
3+
# cloud-api.sh; there is nothing to start locally.
4+
exit 0

0 commit comments

Comments
 (0)