Skip to content

Commit 1bfefb0

Browse files
committed
bench(clickhouse): fix review issues and pin LTS version
- Pass subcommand arg to clickhouse-bench in run-sql-bench.sh for consistency - Use BenchmarkArg + create_benchmark() in main.rs like other engines - Replace `which` with `clickhouse local --version` for binary verification - Pin ClickHouse to LTS release v25.8.18.1 from GitHub Releases Signed-off-by: fastio <pengjian.uestc@gmail.com>
1 parent 64834ed commit 1bfefb0

4 files changed

Lines changed: 40 additions & 35 deletions

File tree

.github/scripts/run-sql-bench.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ fi
132132
# ClickHouse-bench only runs for local benchmarks (clickhouse-local reads local files).
133133
if ! $is_remote && [[ "$has_clickhouse" == "true" ]] && [[ -f "target/release_debug/clickhouse-bench" ]]; then
134134
# shellcheck disable=SC2086
135-
target/release_debug/clickhouse-bench \
135+
target/release_debug/clickhouse-bench "$subcommand" \
136136
-d gh-json \
137137
$opts \
138138
-o ch-results.json

.github/workflows/sql-benchmarks.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,13 @@ jobs:
129129

130130
- name: Install ClickHouse
131131
if: contains(matrix.targets, 'clickhouse:')
132+
env:
133+
CLICKHOUSE_VERSION: "25.8.18.1"
132134
run: |
133-
curl https://clickhouse.com/ | sh
134-
sudo ./clickhouse install
135-
echo "CLICKHOUSE_BINARY=$(which clickhouse)" >> $GITHUB_ENV
135+
wget -qO- "https://github.com/ClickHouse/ClickHouse/releases/download/v${CLICKHOUSE_VERSION}-lts/clickhouse-common-static-${CLICKHOUSE_VERSION}-amd64.tgz" | tar xz
136+
cp clickhouse-common-static-${CLICKHOUSE_VERSION}/usr/bin/clickhouse .
137+
chmod +x clickhouse
138+
echo "CLICKHOUSE_BINARY=$PWD/clickhouse" >> $GITHUB_ENV
136139
137140
- name: Build binaries
138141
shell: bash

benchmarks/clickhouse-bench/src/lib.rs

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl ClickHouseClient {
7070
/// Check that the ClickHouse binary is available.
7171
///
7272
/// For absolute paths, checks that the file exists on disk.
73-
/// For bare names (e.g., `"clickhouse"`), tries to resolve via `$PATH` using `which`.
73+
/// For bare names (e.g., `"clickhouse"`), tries to invoke it to verify it's resolvable.
7474
fn verify_binary(binary: &PathBuf) -> Result<()> {
7575
if binary.is_absolute() {
7676
anyhow::ensure!(
@@ -80,28 +80,31 @@ impl ClickHouseClient {
8080
and ensure it is on $PATH.",
8181
path = binary.display()
8282
);
83-
} else {
84-
// Try to find the binary on $PATH via `which`.
85-
let output = Command::new("which")
86-
.arg(binary.as_os_str())
87-
.output()
88-
.context("Failed to run `which` to locate clickhouse binary")?;
89-
90-
anyhow::ensure!(
91-
output.status.success(),
92-
"ClickHouse binary '{name}' not found on $PATH. \
93-
Install ClickHouse (https://clickhouse.com/docs/en/install) or set \
94-
CLICKHOUSE_BINARY env var to an absolute path before building.",
95-
name = binary.display()
96-
);
97-
98-
let resolved = String::from_utf8_lossy(&output.stdout);
99-
tracing::debug!(
100-
resolved = resolved.trim(),
101-
"Resolved clickhouse binary from PATH"
102-
);
10383
}
10484

85+
// Verify the binary is actually usable by running `clickhouse local --version`.
86+
let output = Command::new(binary.as_os_str())
87+
.args(["local", "--version"])
88+
.output()
89+
.with_context(|| {
90+
format!(
91+
"ClickHouse binary '{name}' not found on $PATH. \
92+
Install ClickHouse (https://clickhouse.com/docs/en/install) or set \
93+
CLICKHOUSE_BINARY env var to an absolute path before building.",
94+
name = binary.display()
95+
)
96+
})?;
97+
98+
anyhow::ensure!(
99+
output.status.success(),
100+
"ClickHouse binary at '{name}' failed to run: {stderr}",
101+
name = binary.display(),
102+
stderr = String::from_utf8_lossy(&output.stderr)
103+
);
104+
105+
let version = String::from_utf8_lossy(&output.stdout);
106+
tracing::debug!(version = version.trim(), "Verified clickhouse binary");
107+
105108
Ok(())
106109
}
107110

benchmarks/clickhouse-bench/src/main.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@ use std::path::PathBuf;
66
use clap::Parser;
77
use clickhouse_bench::ClickHouseClient;
88
use tokio::runtime::Runtime;
9-
use vortex_bench::Benchmark;
9+
use vortex_bench::BenchmarkArg;
1010
use vortex_bench::Engine;
1111
use vortex_bench::Format;
1212
use vortex_bench::Opt;
1313
use vortex_bench::Opts;
14-
use vortex_bench::clickbench::ClickBenchBenchmark;
15-
use vortex_bench::clickbench::Flavor;
14+
use vortex_bench::create_benchmark;
1615
use vortex_bench::create_output_writer;
1716
use vortex_bench::display::DisplayFormat;
1817
use vortex_bench::runner::SqlBenchmarkRunner;
@@ -21,11 +20,14 @@ use vortex_bench::setup_logging_and_tracing;
2120

2221
/// ClickHouse (clickhouse-local) benchmark runner.
2322
///
24-
/// Runs ClickBench queries against Parquet data using clickhouse-local as a performance baseline.
23+
/// Runs queries against Parquet data using clickhouse-local as a performance baseline.
2524
/// This allows comparing ClickHouse's native Parquet reading performance against other engines
2625
/// (DuckDB, DataFusion) on the same hardware and dataset.
2726
#[derive(Parser)]
2827
struct Args {
28+
#[arg(value_enum)]
29+
benchmark: BenchmarkArg,
30+
2931
#[arg(short, long, default_value_t = 5)]
3032
iterations: usize,
3133

@@ -63,10 +65,7 @@ fn main() -> anyhow::Result<()> {
6365

6466
setup_logging_and_tracing(args.verbose, args.tracing)?;
6567

66-
let flavor = opts.get_as::<Flavor>("flavor").unwrap_or_default();
67-
let remote_data_dir = opts.get_as::<String>("remote-data-dir");
68-
let benchmark =
69-
ClickBenchBenchmark::new(flavor, None, remote_data_dir)?.with_engine(Engine::ClickHouse);
68+
let benchmark = create_benchmark(args.benchmark, &opts)?;
7069

7170
let filtered_queries = filter_queries(
7271
benchmark.queries()?,
@@ -83,7 +82,7 @@ fn main() -> anyhow::Result<()> {
8382
let formats = vec![Format::Parquet];
8483

8584
let mut runner = SqlBenchmarkRunner::new(
86-
&benchmark,
85+
benchmark.as_ref(),
8786
Engine::ClickHouse,
8887
formats,
8988
args.track_memory,
@@ -93,7 +92,7 @@ fn main() -> anyhow::Result<()> {
9392
runner.run_all(
9493
&filtered_queries,
9594
args.iterations,
96-
|format| ClickHouseClient::new(&benchmark, format),
95+
|format| ClickHouseClient::new(benchmark.as_ref(), format),
9796
|ctx, _query_idx, _format, query| ctx.execute_query(query),
9897
)?;
9998

0 commit comments

Comments
 (0)