Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions versions/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ logs/

# Rendered per-version cloud-init files
cloud-init.*.sh
.local-server/
2 changes: 2 additions & 0 deletions versions/apply-minvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ def minver_lines(ds):
# Version key mirroring run-version.sh's version_key: a bare build number is a 1.1.<n>
# snapshot; dotted versions use their components (missing -> 0).
def vkey(v):
if v == "master": # the dev build is the newest
return (999999, 0, 0, 0)
if re.fullmatch(r"\d+", v):
return (1, 1, int(v), 0)
parts = v.split(".")
Expand Down
1 change: 1 addition & 0 deletions versions/create/create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ TABLE="${3:?usage: create.sh <version> <dataset> <table>}"
# on supports it. Older 1.1.x builds get the legacy positional engine.
new_syntax() {
local major minor patch
[ "$VERSION" = "master" ] && return 0 # dev build: modern custom-partitioning syntax
IFS=. read -r major minor patch _ <<<"$VERSION"
if [[ "$VERSION" =~ ^[0-9]+$ ]]; then
# Bare build number (earliest 2016 releases, e.g. 53973..54011): custom
Expand Down
4 changes: 2 additions & 2 deletions versions/data.generated.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions versions/fetch-results.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,13 @@ echo "wrote $(ls results/*.json 2>/dev/null | wc -l) result files" >&2
declare -A best
for f in results/*.json; do
v="$(basename "${f}" .json)"
case "${v}" in [0-9]*.[0-9]*) continue ;; esac # already has a dotted prefix
case "${v}" in [0-9]*.[0-9]*|master) continue ;; esac # dotted prefix, or the master tip: keep as-is
av="$(jq -r '.actual_version // empty' "${f}")"; [ -z "${av}" ] && continue
if [ -z "${best[${av}]:-}" ] || [ "${v}" -gt "${best[${av}]}" ]; then best[${av}]="${v}"; fi
done
for f in results/*.json; do
v="$(basename "${f}" .json)"
case "${v}" in [0-9]*.[0-9]*) continue ;; esac
case "${v}" in [0-9]*.[0-9]*|master) continue ;; esac
av="$(jq -r '.actual_version // empty' "${f}")"; [ -z "${av}" ] && continue
if [ "${v}" = "${best[${av}]}" ]; then
jq -cS --arg av "${av}" '.version = $av' "${f}" > results/.rename.tmp
Expand Down
5 changes: 5 additions & 0 deletions versions/list-versions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ emit() { # version date -> resolve provider and print the line
}

{
# The development build: no Docker image -- the "local" provider installs it on the host
# with curl https://clickhouse.com/ | sh (see run-version.sh). Undated (the tip), it
# sorts by its server-reported version once benchmarked.
printf 'master\tlocal\t\n'

# All 1.1.x are kept (including the handful with no image, so they are at
# least listed/"found").
grep -E $'^1\\.1\\.' <<<"${NORM}" | while IFS=$'\t' read -r v date; do
Expand Down
4 changes: 2 additions & 2 deletions versions/queries/tpcds.sql

Large diffs are not rendered by default.

58 changes: 54 additions & 4 deletions versions/run-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ PHASE="${3:-all}"
[ -z "${IMAGE}" ] && IMAGE="$(./list-versions.sh | awk -v v="${VERSION}" '$1==v{print $2}')"
[ -z "${IMAGE}" ] && { echo "no image for ${VERSION}" >&2; exit 1; }

# "local" provider (used for the master/dev build): no Docker -- install ClickHouse on the
# host with the official one-line installer (curl https://clickhouse.com/ | sh) and run the
# server as a background process out of LOCAL_DIR (which then holds its data). Loading,
# queries and sizing are otherwise identical to the Docker path.
LOCAL=""; [ "${IMAGE}" = "local" ] && LOCAL=1
LOCAL_DIR="${HERE}/.local-server"
LOCAL_BIN="${LOCAL_DIR}/clickhouse"

CONTAINER="chver_${VERSION//[^0-9A-Za-z]/_}"
OUT="${HERE}/results/${VERSION}.json"
# Per-table load timings, written during the load phase and read by the bench
Expand Down Expand Up @@ -69,7 +77,14 @@ declare -A TABLES=(
# late crash can't take down the earlier datasets' results as collateral.
QUERY_ORDER="mgbench ssb hits uk ontime taxi coffeeshop tpch tpcds job"

cleanup() { sudo docker rm -f "${CONTAINER}" >/dev/null 2>&1; }
cleanup() {
if [ -n "${LOCAL}" ]; then
[ -f "${LOCAL_DIR}/server.pid" ] && kill "$(cat "${LOCAL_DIR}/server.pid")" 2>/dev/null
pkill -f "${LOCAL_BIN} server" 2>/dev/null
return 0
fi
sudo docker rm -f "${CONTAINER}" >/dev/null 2>&1
}
# The load phase must leave the container running for the later bench phase;
# all/bench tear it down on exit.
[ "${PHASE}" != "load" ] && trap cleanup EXIT
Expand Down Expand Up @@ -100,8 +115,11 @@ exec_client() { sudo ${CH_TIMEOUT:+timeout ${CH_TIMEOUT}} docker exec -i -e H
sidecar_client() { sudo ${CH_TIMEOUT:+timeout ${CH_TIMEOUT}} docker run --rm -i -e HOME=/tmp -e TZ=UTC \
-v /usr/share/zoneinfo:/usr/share/zoneinfo:ro \
--network "container:${CONTAINER}" "${CLIENT_IMAGE}" "$@"; }
# local provider: the installed binary, connecting to the host server over TCP.
local_client() { ${CH_TIMEOUT:+timeout ${CH_TIMEOUT}} env HOME=/tmp TZ=UTC "${LOCAL_BIN}" client "$@"; }
client() {
case "${CLIENT_MODE}" in
local) local_client "$@" ;;
sidecar) sidecar_client "$@" ;;
*) exec_client "$@" ;;
esac
Expand Down Expand Up @@ -161,6 +179,24 @@ ensure_built_image() {

start_server() {
cleanup
if [ -n "${LOCAL}" ]; then
# No Docker: install with the official one-liner (once) and run the server on the
# host, out of LOCAL_DIR so its data lands there.
echo "starting ${VERSION} via the local installer (curl https://clickhouse.com/ | sh)" >&2
mkdir -p "${LOCAL_DIR}"
[ -x "${LOCAL_BIN}" ] || ( cd "${LOCAL_DIR}" && curl -fsSL https://clickhouse.com/ | sh ) >&2
[ -x "${LOCAL_BIN}" ] || { echo "local install failed: ${LOCAL_BIN} missing" >&2; return 1; }
( cd "${LOCAL_DIR}" && HOME=/tmp TZ=UTC nohup ./clickhouse server > server.log 2>&1 & echo $! > server.pid )
CLIENT_MODE=local
local i
for i in $(seq 1 "${READY_TIMEOUT:-90}"); do
local_client --query "SELECT 1" >/dev/null 2>&1 && return 0
sleep 1
done
echo "local server ${VERSION} did not become ready; last log lines:" >&2
tail -20 "${LOCAL_DIR}/server.log" >&2 2>&1 || true
return 1
fi
if [ "${IMAGE}" = "package" ]; then
# Fallback provider: install the .deb release into a stock Ubuntu image.
echo "starting ${VERSION} via package-in-ubuntu fallback" >&2
Expand Down Expand Up @@ -368,6 +404,13 @@ launch_daemon_in_container() {
}
wait_alive() { local i; for i in $(seq 1 "${1:-180}"); do server_alive && return 0; sleep 1; done; return 1; }
revive_server() {
if [ -n "${LOCAL}" ]; then
echo "${VERSION}: relaunching local server; recent log:" >&2
tail -8 "${LOCAL_DIR}/server.log" 2>&1 | sed 's/^/ | /' >&2 || true
( cd "${LOCAL_DIR}" && HOME=/tmp TZ=UTC nohup ./clickhouse server >> server.log 2>&1 & echo $! > server.pid )
wait_alive "${REVIVE_TIMEOUT:-180}" && { echo "${VERSION}: local server back up" >&2; return 0; }
echo "${VERSION}: local server did not come back" >&2; return 1
fi
local running
running="$(sudo docker inspect -f '{{.State.Running}}' "${CONTAINER}" 2>/dev/null)"
echo "${VERSION}: reviving server (container running=${running:-unknown}); recent container logs:" >&2
Expand Down Expand Up @@ -403,7 +446,7 @@ report_sizes() {
# The benchmark tables live in per-dataset databases; exclude the server's
# own system databases.
out=$(client --query "SELECT database, table, sum(bytes_on_disk) AS size FROM system.parts WHERE database NOT IN ('system', 'information_schema', 'INFORMATION_SCHEMA') GROUP BY database, table ORDER BY database, table FORMAT TabSeparated" </dev/null 2>/dev/null)
if [ -n "${out}" ]; then
if [ -n "${out}" ] || [ -n "${LOCAL}" ]; then
printf '%s\n' "${out}"
else
echo "(system.parts unavailable — measuring the data directory)"
Expand All @@ -424,6 +467,7 @@ fmt_err() { printf '%s' "$1" | tr '\n\t' ' ' | sed 's/ */ /g; s/^ //' | cut -c
# so 1.1.54378 and the bare 53982 both sort *below* any calendar release.
version_key() {
local v="$1" a b c d
[ "$v" = "master" ] && { echo "999999 0 0 0"; return; } # the dev build is the newest
if [[ "$v" =~ ^[0-9]+$ ]]; then echo "1 1 $v 0"; return; fi
IFS='.' read -r a b c d _ <<<"$v"
echo "${a:-0} ${b:-0} ${c:-0} ${d:-0}"
Expand Down Expand Up @@ -516,6 +560,12 @@ run_query() {
# Attach to an already-running, already-loaded container (bench phase): detect
# the client mode without (re)starting or wiping the container.
detect_client() {
if [ -n "${LOCAL}" ]; then
CLIENT_MODE=local
local i
for i in $(seq 1 30); do local_client --query "SELECT 1" >/dev/null 2>&1 && return 0; sleep 1; done
echo "local server for ${VERSION} not answering" >&2; return 1
fi
sudo docker ps -q -f "name=^${CONTAINER}$" | grep -q . || { echo "container ${CONTAINER} not running" >&2; return 1; }
[ "${IMAGE}" != "package" ] && [ -n "${CLIENT_IMAGE}" ] && sudo docker pull "${CLIENT_IMAGE}" >/dev/null 2>&1
local i
Expand Down Expand Up @@ -547,7 +597,7 @@ emit_load_time_json() {
emit_data_size_json() {
local out loaded=" ${1:-} "
out=$(client --query "SELECT database, sum(bytes_on_disk) FROM system.parts WHERE active AND database NOT IN ('system', 'information_schema', 'INFORMATION_SCHEMA') GROUP BY database FORMAT TabSeparated" </dev/null 2>/dev/null)
if [ -z "${out}" ]; then
if [ -z "${out}" ] && [ -z "${LOCAL}" ]; then
# No system.parts: sum the byte size of each dataset's data directory in the
# container (works for both Log and MergeTree; -L follows the store/ symlinks).
out=$(sudo docker exec "${CONTAINER}" sh -c '
Expand Down Expand Up @@ -579,7 +629,7 @@ release_date() {
server_version() {
local v rev
v=$(client --query "SELECT version()" 2>/dev/null | tr -d '\r')
if [ -z "${v}" ]; then
if [ -z "${v}" ] && [ -z "${LOCAL}" ]; then
rev=$(sudo docker exec "${CONTAINER}" cat /clickhouse-revision 2>/dev/null | tr -d '\r\n ')
[ -n "${rev}" ] && v="0.0.${rev}"
fi
Expand Down
Loading