Skip to content

Make the rand performance test call the functions it measures - #131157

Merged
Algunenano merged 1 commit into
ClickHouse:masterfrom
groeneai:rand-perf-test-call-functions
Nov 13, 2026
Merged

Algunenano merged 1 commit into
ClickHouse:masterfrom
groeneai:rand-perf-test-call-functions

Conversation

@groeneai

@groeneai groeneai commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #110105
Related: #101039

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):

...

Description

rand #2 turned Performance Comparison (arm_release, master_head, 3/6) red on #110105 (6.4 -> 8.1 ms), and rand #3 did the same on #101039. Neither PR touches these functions.

The four queries are SELECT count() FROM (SELECT f() FROM zeros(N)). count() reads no column of the subquery, so the plan is only ReadFromStorage (SystemZeros) -> Aggregating, and rand, rand64, randUniform and generateUUIDv4 are never called. In CI, FunctionExecute is 0 in every run of all four queries on both architectures: the test times count() over zeros(). This started when the analyzer became the default (#61652). On master, rand #2 went from 246 ms on 2024-03-26 to 6.3 ms on 2024-03-27.

Queries 0-3 get disabled="1", which keeps their numbers and text. Queries 4-7 run the same functions with the same row counts as SELECT count() FROM zeros(N) WHERE NOT ignore(f()), the form used by random_string.xml and synthetic_hardware_benchmark.xml. ignore is not constant-folded, so its argument is computed for every row. The new queries have no master history yet.

Validation (x86, amd_release of the base commit):

  • perf.py --print-queries keeps 0-3 byte-identical.
  • system.query_log shows FunctionExecute 0 for 0-3 and 4587-45867 for 4-7.
  • Three A/A perf.py runs with the CI flags, both servers pinned to the same 8 cores, skip 0-3 and time 4-7 at 66-217 ms. The two servers agree within 1.5%. In the same setup, master's queries 0-3 move by up to 10.1%.
  • This PR's arm jobs measure the new queries on arm.

highlight #0/#1 and distributed_aggregation #0 have the same pruned count() shape. They are not changed here.

🤖 Generated with Claude Code


Workflow [PR]
Sync PR [sync-upstream/pr/131157]

Version info

  • Merged into: 26.11.1.2176-master (included in 26.11 and later)

The four queries of `rand.xml` have the shape
`SELECT count() FROM (SELECT f() FROM zeros(N))`. `count()` reads no column
of the subquery, so the projection is dropped and `f()` is never called: in
CI `FunctionExecute` is 0 in every run of all four queries on both
architectures, and the queries time `count()` over `zeros()` (4-8 ms for
queries 2 and 3), which is noise. This started with the analyzer becoming
the default (ClickHouse#61652): on master `rand ClickHouse#2` went from 246 ms on 2024-03-26 to
6.3 ms on 2024-03-27.

Performance test queries keep their numbers, so queries 0-3 are disabled
(`disabled="1"`, text unchanged) and queries 4-7 are appended in the
`WHERE NOT ignore(f())` form used by `random_string.xml` and
`synthetic_hardware_benchmark.xml`, with the same row counts. `ignore` is
never constant-folded, so its argument is computed for every row.

Related: ClickHouse#110105, ClickHouse#101039

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 1 finding) plus my own review (1 nit).

# Sev Finding Verdict Evidence / action
1 ⚠️ No automated oracle checks that queries 4-7 keep executing their functions (tests/performance/rand.xml:17-20) DISAGREE ignore is never constant-folded or short-circuited (src/Functions/ignore.cpp:38-39); the same idiom executes in every CI run (random_string #0, synthetic_hardware_benchmark #0: FunctionExecute 4587); queries 4-7 measured 45867 / 4587. A per-query plan or ProfileEvents assertion is a perf.py feature no test has (113 tests use WHERE NOT ignore(...)), so it belongs in a separate harness PR.
2 💡 highlight #0/#1 and distributed_aggregation #0 have the same pruned count() shape AGREE, noted Named in the description; other tests, not changed here.

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are
terminal per finding.

Session id: cron:clickhouse-review-slot-10:20261112-234200

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @Algunenano, could you review this? Make the rand performance test call the functions it measures: queries 0-3 never called rand/rand64/randUniform/generateUUIDv4, so they are disabled and replaced by WHERE NOT ignore(f()) queries

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Yes. On the amd_release build of the base commit, EXPLAIN actions = 1 of queries 0-3 has no function node, and FunctionExecute is 0 in 7 of 7 runs of each. That matches CI, where it is 0 in every run.
b Root cause explained? count() reads no column of the subquery, so the projection is pruned and f() never runs. The test then times count() over zeros() (4-8 ms), and that number moves more between runs than the dashboard threshold allows. This started with #61652.
c Fix matches root cause? Yes. The function's output now feeds the filter through ignore, which is never constant-folded or short-circuited, so the function runs on every row. No threshold was widened and no query was removed.
d Test intent preserved / new tests added? Yes. The test again measures rand, rand64, randUniform and generateUUIDv4 at the same row counts. The old queries stay disabled, so their history is kept.
e Both directions demonstrated? Yes. Queries 0-3 show FunctionExecute 0 and no function in the plan. Queries 4-7 show 45867 calls (1e9 rows) or 4587 (1e8 rows), with the function in the filter column. Three A/A perf.py runs agree within 1.5%.
f Fix is general across code paths? No source change. highlight #0/#1 and distributed_aggregation #0 have the same pruned count() shape. They are named in the description and not changed in this PR.
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A (test-only). All four functions are covered at their original row counts.
h Backward compatible? (maintainer-approved exception only) Yes. No settings or source changes. Queries 0-3 keep their numbers and history.
i Invariants and contracts preserved? The history key (test, query number) is preserved. Queries 0-3 are byte-identical in perf.py --print-queries, and 4-7 are numbers this test never used before. Results are deterministic (count() = N).

Session id: cron:clickhouse-impl-slot-7:20261112-232400

@clickhouse-gh

clickhouse-gh Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [e8d2163]

Summary: ✅


AI Review

Summary

PR #131157 at e8d2163d218f413b19e5b44b24761164cf546fcc replaces four pruned random-function benchmarks with queries that force evaluation through ignore, preserving the disabled queries' history indexes and original row counts. No actionable findings after reviewing the full diff, current implementations, performance harness, and all prior discussion.

Missing context / blind spots
  • ⚠️ No local ClickHouse build was available, and the current CI performance reports contain no query measurements. Runtime evidence comes from the author's reported query plans, FunctionExecute counts, and three A/A runs; a completed CI run of rand would provide independent confirmation.
Final Verdict

Status: ✅ Approve.

@clickhouse-gh clickhouse-gh Bot added pr-ci can be tested Allows running workflows for external contributors comp-testing Test content only (no production code). labels Nov 13, 2026
@Algunenano Algunenano self-assigned this Nov 13, 2026
@Algunenano
Algunenano added this pull request to the merge queue Nov 13, 2026
Merged via the queue into ClickHouse:master with commit 7d943bb Nov 13, 2026
408 of 409 checks passed
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 13, 2026
@clickhouse-gh clickhouse-gh Bot added comp-regular-function Regular scalar functions: string processing, data conversion, arithmetic, math, comparison, condi... and removed comp-testing Test content only (no production code). labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-regular-function Regular scalar functions: string processing, data conversion, arithmetic, math, comparison, condi... 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.

3 participants