Skip to content

Rebuild perf-test hits datasets by re-inserting instead of attaching - #110009

Merged
Algunenano merged 12 commits into
ClickHouse:masterfrom
Algunenano:perf-reinsert-hits-datasets
Jul 20, 2026
Merged

Algunenano merged 12 commits into
ClickHouse:masterfrom
Algunenano:perf-reinsert-hits-datasets

Conversation

@Algunenano

@Algunenano Algunenano commented Jul 10, 2026 •

Copy link
Copy Markdown
Member

Performance tests populated the hits tables (test.hits, hits_10m_single, hits_100m_single) by attaching the dataset tarballs directly, so the parts kept their frozen on-disk format: non-adaptive marks, no sparse serialization, no statistics, and a single pre-merged part. Write-time default changes (for example sparse columns, statistics, or in the near future compute_exact_num_defaults_for_sparse_columns) were therefore never exercised on these datasets.

Now each server re-inserts the hits datasets into its final tables on startup, then runs OPTIMIZE ... FINAL to collapse them back to a single part matching the original layout. The parts are written by that server's own binary and settings, so a PR that changes a write-time default is reflected on the tested (right) side. The left (reference) and right servers are populated independently and in parallel; within a server the three tables are rebuilt sequentially (concurrent inserts would exceed the per-user memory limit).

Scope: this covers the hits datasets, which back the bulk of the suite (including clickbench.xml). The other attached datasets (tpch, tpcds, values) are still read from their frozen tarball parts, so write-time defaults are not yet exercised on those workloads; rebuilding them the same way can be a follow-up.

Marked with the ci-performance label so the Performance Comparison runs on both AMD and ARM (ARM runs by default; the label enables AMD).

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Not for changelog.

Version info

  • Merged into: 26.7.1.1215 (included in 26.7 and later)

The performance-comparison setup attached the dataset tarballs directly,
so the hits tables kept their frozen on-disk format: non-adaptive marks,
no sparse serialization, no statistics, and a single pre-merged part.
Changes to write-time defaults (for example sparse columns or
`compute_exact_num_defaults_for_sparse_columns`) were therefore never
exercised by the performance tests.

Each server now re-inserts the attached datasets into its final tables
on startup, then runs `OPTIMIZE ... FINAL` to collapse them back to a
single part matching the original layout. The parts are written by that
server's own binary and settings, so a PR that changes a write-time
default is reflected on the tested (right) side. The left (reference) and
right servers are populated independently and in parallel.

Co-Authored-By: Claude Fable 5 <[email protected]>
@Algunenano Algunenano added the ci-performance performance only label Jul 10, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [92062c9]

Summary: ✅


AI Review

Summary

This PR changes the performance-comparison setup so each server rebuilds the hits datasets via INSERT ... SELECT and OPTIMIZE ... FINAL instead of attaching frozen tarball parts directly, which should make write-time defaults visible on the measured side. The populate/retry logic in the current code looks internally coherent, but the PR still lacks the one piece of evidence its contract needs: a successful Performance Comparison run, or an equivalent local run, that actually exercises the new Populate stage.

Findings

⚠️ [dismissed by author -- https://github.com/ClickHouse/ClickHouse/pull/110009#discussion_r3587519998] The new restart -> populate -> tests -> report path still has not been proven to run. As of July 20, 2026, the PR still carries only the pr-ci label, and the fetched Praktika summary for PR #110009 still reports 173 jobs with 161 skipped and no Performance Comparison shards. That means this CI-only path can still merge without ever being executed once.
Suggested fix: rerun at least one Performance Comparison shard with the ci-performance label, or attach an equivalent local performance_tests.py log that includes a successful Populate stage.

Final Verdict

⚠️ Not ready to approve until the new performance-comparison path is exercised at least once.

@clickhouse-gh clickhouse-gh Bot added the pr-ci label Jul 10, 2026
Algunenano and others added 3 commits July 13, 2026 11:44
The CI performance job runs `ci/jobs/performance_tests.py`, which does its
own dataset setup and only calls `compare.sh` for the report stage. The
previous commit changed `compare.sh`'s `configure`/`restart`, which the CI
never executes, so the re-insert never ran. Revert that dead change and
implement the same logic in `performance_tests.py`.

The configure step no longer starts a preconfig server to rename
`datasets.hits_v1` to `test.hits`; the datasets stay attached as-is. After
both servers start, each re-inserts its hits datasets and runs
`OPTIMIZE ... FINAL` to collapse them back to a single part matching the
original layout. Parts are written by that server's own binary and
settings, so a PR changing a write-time default is reflected on the tested
(right) side. Both servers are populated in parallel.

Co-Authored-By: Claude Fable 5 <[email protected]>
…rver

Removing the preconfig server also removed the side effect that created
`ci/tmp/coordination0`, which the configure step copied into each server's
keeper storage, so `cp` failed. Create each server's coordination dir
directly instead; the embedded, non-replicated keeper bootstraps from an
empty dir.

Co-Authored-By: Claude Fable 5 <[email protected]>
The hits datasets are attached in Ordinary databases (default, datasets),
and EXCHANGE TABLES is only supported in Atomic databases, so the in-place
rebuild of hits_10m_single / hits_100m_single failed with NOT_IMPLEMENTED.
Swap the freshly-built table in with a two-table RENAME, which works in
Ordinary databases too.

Co-Authored-By: Claude Fable 5 <[email protected]>
@Algunenano Algunenano removed the ci-performance performance only label Jul 14, 2026
Each server rebuilt its three hits tables sequentially, so the two small
tables (~20s each) added on top of hits_100m_single (~13min). Rebuild all
three in parallel instead: the small tables finish within the big table's
window, saving ~40s per shard. All tables still get OPTIMIZE FINAL to a
single part, so no background merges run during the tests.

Co-Authored-By: Claude Fable 5 <[email protected]>
Comment thread ci/jobs/performance_tests.py Resolved
Rebuilding the three tables in parallel on one server OOMed: the inserts
share the per-user memory limit (~28GiB) and hits_100m_single alone uses
~21GiB, so the OvercommitTracker killed the concurrent test.hits insert.
Go back to sequential rebuilds (the two servers are still populated in
parallel, which fits since each has its own user memory tracker).

Also stop using test.hits existence as the "done" marker: with rebuilds it
was not a reliable signal (the in-place *_single tables exist from the
tarball before being rebuilt). Create a dedicated test._populate_done
marker only after all three tables are rebuilt, and drop any leftover
target at the start of rebuild_table, so a retry after a mid-run failure
re-runs the whole populate instead of skipping it.

Co-Authored-By: Claude Fable 5 <[email protected]>
Comment thread ci/jobs/performance_tests.py Resolved
rebuild_table treated any missing source as a benign skip, so if an
in-place dataset (default.hits_10m_single / default.hits_100m_single)
failed to attach, populate_data still wrote test._populate_done and every
later restart skipped the rebuild, leaving that dataset in the frozen
tarball format. Only the datasets.hits_v1 -> test.hits retry (source
already consumed into an existing destination) is a legitimate skip; every
other missing source now raises so the job fails instead of silently
marking an unrebuilt dataset as done.

Co-Authored-By: Claude Fable 5 <[email protected]>
Comment thread ci/jobs/performance_tests.py Resolved
Only the hits datasets are re-inserted; tpch, tpcds and values still read
their frozen tarball parts, so write-time defaults are not exercised on
those workloads. Make that scope explicit in populate_data.

Co-Authored-By: Claude Fable 5 <[email protected]>
Comment thread ci/jobs/performance_tests.py Resolved
@Algunenano Algunenano added the ci-performance performance only label Jul 16, 2026
Algunenano and others added 3 commits July 16, 2026 18:30
eqmed.sql runs a randomization test for the median difference between the
two versions. It cross-joined each query's measurements with
numbers(1, 10000) and did `order by rand()`, so a query with 1000
measurements built and sorted 10M rows in memory: ~22 GiB peak and ~15s,
single-threaded. That 22 GiB spike is why the analyze stage caps
concurrency at MemTotal/15.

Two changes, same statistic (10000 iterations, exact medians):

- Keep each query's measurements as one array and reshuffle it per
  iteration (arrayShuffle + arrayReduce('medianExactForEach', ...) on each
  half), with max_block_size bounding how many shuffled copies exist at
  once, instead of materializing and sorting numbers*T rows.
- Only randomize metrics that actually vary across the measurements. A
  constant metric has identical medians in every split, so its threshold
  is exactly 0 (which the old query also produced); most of the ~230
  ProfileEvents are constant per query. The threshold is scattered back to
  full width with 0 for the constant metrics.

Verified on 505 real query inputs from a CI run: the deterministic
columns (left/right medians, diff) are byte-identical, and the randomized
threshold is statistically identical (median ratio 1.0; the only
differences are Monte-Carlo boundary flips the old query shows run to run
as well). On the heaviest query (1000 measurements) peak memory drops
from 22.5 GiB to 788 MiB and time from 15.4s to 2.48s; total CPU over all
505 queries drops from 896s to 225s.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
get_profiles dumped `select *` from system.query_log for both servers
(~120 MiB each, 85 columns), parsed downstream by analyze_queries and
report(). Only six columns are actually read by the report (query_id,
ProfileEvents, query_duration_ms, memory_usage, read_bytes,
written_bytes); the rest are only ever looked at by a human debugging a
run.

Dump a curated set instead: the six report columns plus the ones useful
for manual debugging (query text, Settings, timings, row/byte counts,
exceptions). This drops ~70 niche columns (initial_query_*, transaction_id,
thread_ids, used_*, client_*, microsecond-precision duplicates, ...) and
shrinks each dump from ~120 MiB to ~92 MiB, so the artifact is smaller and
analyze/report parse less. ProfileEvents and Settings, the two large
columns, are kept.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@Algunenano Algunenano removed the ci-performance performance only label Jul 20, 2026
@Algunenano
Algunenano added this pull request to the merge queue Jul 20, 2026
Merged via the queue into ClickHouse:master with commit a2cea94 Jul 20, 2026
177 checks passed
@Algunenano
Algunenano deleted the perf-reinsert-hits-datasets branch July 20, 2026 13:16
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 20, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…ts-datasets

Rebuild perf-test hits datasets by re-inserting instead of attaching
alexey-milovidov pushed a commit to Onyx2406/ClickHouse that referenced this pull request Oct 15, 2026
Since ClickHouse#110009 each perf server rebuilds hits_10m_single, hits_100m_single
and datasets.hits_v1 -> test.hits itself: a 16-thread INSERT ... SELECT,
then OPTIMIZE FINAL. The INSERT splits the rows into parts
nondeterministically, and the vertical merge with variable adaptive
granularity (blocks_are_granules_size in MergeTask) makes every merged
granule follow the input parts' granules, so the left and right servers
get different granule boundaries. order_by_read_in_order ClickHouse#1 reads in
reverse order, only the last granule, whose size is the remainder of that
layout: 510 vs 6041 rows on PR 117972 arm 2/6 (+18%), 958 vs 7977 on
PR 119090 arm 4/6 (+50.9%). The layout lasts for the whole job, so the
difference is perfectly separated and reproducible, and it reds shards.

With use_const_adaptive_granularity the merged part's rows per granule is
one constant computed from its total rows and bytes, capped at
index_granularity. hits rows are 553-713 bytes, far below 10 MiB / 8192,
so both servers get 8192-row granules. The setting only affects parts
written while it is set, so it is reset after OPTIMIZE FINAL: the part
keeps its granules, and CREATE TABLE ... AS clones
(trivial_insert_select_from_files measures an INSERT into one) keep the
default insert path.

The double-check-perf-tests mirror of rebuild_table gets the same two
statements, so --populate keeps matching CI.

Validated on two local servers with the official master build and the CI
datasets, driving the harness function itself: before, every rebuild pair
differed (hits_100m_single query ClickHouse#1 read 7977 vs 993 rows); after, all
pairs are identical (256 rows).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-ci pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants