Skip to content

Read the dataset from the copy in this machine's region - #1091

Merged
alexey-milovidov merged 3 commits into
mainfrom
region-aware-dataset-bucket
Jul 26, 2026
Merged

Read the dataset from the copy in this machine's region#1091
alexey-milovidov merged 3 commits into
mainfrom
region-aware-dataset-bucket

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Jul 26, 2026

Copy link
Copy Markdown
Member

The problem

The daily fleet moved from eu-central-1 to us-east-1 on 2026-07-20 (08bab92, "the region defaults to us-east-1 (cheaper)"), but the public datasets live in clickhouse-public-datasets, which is in eu-central-1. Every entry that reads S3 at query time has been going transatlantic since.

clickhouse-web took the worst of it — roughly 30x on every machine size:

machine 2026-07-19 2026-07-25 ratio
c6a.large 459 s 10114 s 22.0x
c6a.xlarge 170 s 5306 s 31.2x
c6a.2xlarge 91 s 2970 s 32.7x
c6a.4xlarge 52 s 1730 s 33.4x
c8g.4xlarge 50 s 1791 s 35.8x
c6a.metal 21 s 754 s 35.6x
c7a.metal-48xl 19 s 628 s 32.7x
c8g.metal-48xl 21 s 631 s 30.4x

The ratio barely moves across machine sizes and is uniform across all 43 queries: this is round-trip latency, not CPU. The web disk issues many small granule-level range reads, and clickhouse-web/query drops the filesystem cache before every try, so all three tries pay it. clickhouse-datalake, whose reads are large and sequential, lost a milder 3.8x on cold (119 s → 452 s). Entries that download the data first were unaffected and stayed flat, which is what rules out the machines themselves.

The change

The ClickBench paths are now mirrored in clickhouse-public-datasets--us-east-1. lib/dataset-bucket.sh asks the instance metadata service where we are and picks the nearer copy:

  • eu-*clickhouse-public-datasets (eu-west-1 and eu-north-1 are far closer to Frankfurt than us-east-1 is)
  • anything else → clickhouse-public-datasets--us-east-1
  • IMDS unreachable (not EC2, or another cloud) → the original bucket, which is what every non-EC2 run has always used
  • CLICKBENCH_DATASET_BUCKET=<name> overrides all of it

The create.sql files are rewritten on the way into the client rather than templated, so they stay valid standalone SQL and the diff is one line per load script. bench_dataset_sql covers the three forms they use: the virtual-hosted hostname with or without a region, the s3:// scheme, and the region DuckDB's S3 secret signs with.

file change
lib/dataset-bucket.sh new
clickhouse-web/load bench_dataset_sql < create.sql | clickhouse-client
clickhouse-datalake{,-partitioned}/load --query="$(bench_dataset_sql < create.sql)"
duckdb-datalake{,-partitioned}/load rewrite to a temp file, -f that (DuckDB needs a real file)
versions/cloud-init.sh.in BUCKET from ${DATASET_HOST}
clickhouse-web/install dropped the stale "expects to run in eu-central-1" note

versions/prepare-data/ is deliberately left alone: those scripts are one-off tools for regenerating the versions-benchmark files, not part of any benchmark run. The files they produce are mirrored in full, so the versions suite itself runs anywhere.

Testing

Against the live bucket, ClickHouse S3 single-file and {0..99} glob, the web disk, and both DuckDB entries through their real ./load scripts all return 99997497 rows and 630500 for Q1 — identical from either bucket:

path eu bucket us-east-1 bucket
ClickHouse S3, single parquet 630500 630500
ClickHouse S3, {0..99} glob 630500 630500
ClickHouse web disk 630500 630500
DuckDB https / s3:// glob 630500 both

A full key-and-size inventory diff confirms the mirror is complete for everything the benchmarks read. Region mapping is checked for seven regions with faked IMDS responses, non-AWS IMDS falls back correctly, and sourcing is safe under set -euo pipefail. Off-EC2 detection costs 1s once per load.

Not covered: IMDS auto-detection never fires on a dev box, so the first real daily run is what confirms it. If it works, clickhouse-web on c6a.4xlarge should drop from ~1730 s back to ~52 s.

Related

The Tier 2 entries that reference the bucket (trino-datalake, presto-datalake, athena, redshift, snowflake, singlestore, crunchy-bridge, databricks, s3select) are untouched — they are managed services with their own fixed regions, not our EC2 fleet, and some are pinned to eu-central-1 on purpose.

The unconditional SYSTEM DROP FILESYSTEM CACHE in clickhouse-web/query — what turned a latency penalty into a 30x one — is fixed separately in #1092.

🤖 Generated with Claude Code

The daily fleet moved from eu-central-1 to us-east-1 on 2026-07-20
(08bab92, "the region defaults to us-east-1 (cheaper)"), but the public
datasets live in clickhouse-public-datasets, which is in eu-central-1.
Every entry that reads S3 at query time has been going transatlantic since.

clickhouse-web took the worst of it, ~30x on every machine size:

  machine           2026-07-19   2026-07-25   ratio
  c6a.large            459 s      10114 s     22.0x
  c6a.xlarge           170 s       5306 s     31.2x
  c6a.2xlarge           91 s       2970 s     32.7x
  c6a.4xlarge           52 s       1730 s     33.4x
  c8g.4xlarge           50 s       1791 s     35.8x
  c6a.metal             21 s        754 s     35.6x
  c7a.metal-48xl        19 s        628 s     32.7x
  c8g.metal-48xl        21 s        631 s     30.4x

The ratio barely moves across machine sizes and is uniform across all 43
queries: this is round-trip latency, not CPU. The web disk issues many small
granule-level range reads, and clickhouse-web/query drops the filesystem
cache before every try, so all three tries pay it. clickhouse-datalake, whose
reads are large and sequential, lost a milder 3.8x on cold (119 s -> 452 s).
Entries that download the data first are unaffected and stayed flat.

The ClickBench paths are now mirrored in clickhouse-public-datasets--us-east-1.
lib/dataset-bucket.sh asks the instance metadata service where we are and
picks the nearer copy: eu-* keeps the original bucket, everything else takes
the mirror. If IMDS is unreachable (not EC2, or another cloud) we keep the
original, which is what every non-EC2 run has always used;
CLICKBENCH_DATASET_BUCKET overrides the choice.

The create.sql files are rewritten on the way into the client rather than
templated, so they stay valid standalone SQL. bench_dataset_sql covers the
three forms they use: the virtual-hosted hostname with or without a region,
the s3:// scheme, and the region DuckDB's S3 secret signs with.

versions/prepare-data/ is left alone: those scripts are one-off tools for
regenerating the versions-benchmark files, not part of any benchmark run.
The files they produce are mirrored in full, so the versions suite itself
runs anywhere.

Verified against the live bucket: ClickHouse S3 single-file and {0..99} glob,
the web disk, and both DuckDB entries through their real ./load scripts all
return 99997497 rows and 630500 for Q1, identical from either bucket. Region
mapping checked for seven regions with faked IMDS responses, and sourcing is
safe under set -euo pipefail.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…rtitioned, clickhouse-web, duckdb-datalake, duckdb-datalake-partitioned (c6a.2xlarge, c6a.4xlarge, c6a.large, c6a.metal, c6a.xlarge, c7a.metal-48xl, c8g.4xlarge, c8g.metal-48xl)
@github-actions

Copy link
Copy Markdown
Contributor

Results for clickhouse-datalake are ready for: c6a.2xlarge, c6a.4xlarge, c6a.metal, c6a.xlarge, c7a.metal-48xl, c8g.4xlarge, c8g.metal-48xl.
Results for clickhouse-datalake-partitioned are ready for: c6a.2xlarge, c6a.4xlarge, c6a.metal, c6a.xlarge, c7a.metal-48xl, c8g.4xlarge, c8g.metal-48xl.
Results for clickhouse-web are ready for: c6a.2xlarge, c6a.4xlarge, c6a.metal, c6a.xlarge, c7a.metal-48xl, c8g.4xlarge, c8g.metal-48xl.
Results for duckdb-datalake are ready for: c6a.2xlarge, c6a.4xlarge, c6a.large, c6a.metal, c6a.xlarge, c7a.metal-48xl, c8g.4xlarge, c8g.metal-48xl.
Results for duckdb-datalake-partitioned are ready for: c6a.2xlarge, c6a.4xlarge, c6a.metal, c6a.xlarge, c7a.metal-48xl, c8g.4xlarge, c8g.metal-48xl.
The result files are committed as db43d2a.

Logs:

@alexey-milovidov alexey-milovidov self-assigned this Jul 26, 2026
…rtitioned, clickhouse-web, duckdb-datalake, duckdb-datalake-partitioned (c6a.large, t3a.small)
@github-actions

Copy link
Copy Markdown
Contributor

Results for clickhouse-datalake are ready for: c6a.large, t3a.small.
Results for clickhouse-datalake-partitioned are ready for: c6a.large.
Results for clickhouse-web are ready for: c6a.large, t3a.small.
Results for duckdb-datalake are ready for: t3a.small.
Results for duckdb-datalake-partitioned are ready for: c6a.large, t3a.small.
The result files are committed as cc83bb3.

Logs:

@alexey-milovidov
alexey-milovidov merged commit dcfe208 into main Jul 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Results for clickhouse-datalake-partitioned are ready for: t3a.small.

Logs:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

machine:all PR benchmark on every machine type

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant