Skip to content

Run six jit_sort queries above 1 s on half of their rows - #131761

Open
groeneai wants to merge 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/perf-jit-sort-nullable-half-rows
Open

groeneai wants to merge 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/perf-jit-sort-nullable-half-rows

Conversation

@groeneai

@groeneai groeneai commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #129258

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

The Nullable(UInt64) tables of the three {table} queries of jit_sort.xml (query indexes 2, 3, 6, 7, 10, 11) take 1.10-1.25 s on MasterCI amd and 1.13-1.28 s on arm. Each sorts all 10M rows of a 6-column Nullable table; the perf harness sets compile_sort_description = 0, so this is the interpreted sort.

No existing query number or text changes: 3 queries (12 numbered entries) are disabled and 6 (12 entries) are appended, as 14-25. They run verbatim over the two plain tables ({plain_table}: the sub-second expansions the marker also stops) and over the two Nullable tables ({nullable_table}) with WHERE key % 2 = 0, which keeps half of every block.

Measured with perf.py on official MasterCI release builds, 8 pinned cores: the Nullable copies take 0.49-0.55 of their originals' time, about 550-680 ms on amd and 570-700 ms on arm, so about 30 s less query time per master perf job. At 8 and 12 threads they run the same sort processors, the same plan steps (the filter becomes a PREWHERE of the read) and the same number of read blocks, with half of the sorted rows. On the four MasterCI build pairs that moved these queries by 11-18% on CI, the copies move like the originals: 3a52fa3 -> 2f953ee makes the one-key originals 1.16-1.18x slower and their copies 1.14-1.18x, 1b7e6cd -> ca1dbe5 the 3- and 5-key ones 1.27-1.31x and 1.22-1.30x, abd6a6d -> 8f53dd7 0.78x and 0.77-0.81x.

Query 13 (hits_100m_single, 1.24 s on amd, 0.75 s on arm) stays: a copy on hits_10m_single would run about 0.08 s on arm, under the 0.1 s the perf README asks for. 14 queries stay enabled, as before. The plain copies restart the history of six sub-second queries (0, 1, 4, 5, 8, 9).

🤖 Generated with Claude Code


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

The `Nullable(UInt64)` expansions of the three `{table}` queries of
`tests/performance/jit_sort.xml` (query indexes 2, 3, 6, 7, 10, 11) have
MasterCI medians of 1.10-1.25 s on amd and 1.13-1.28 s on arm: each sorts
all 10M rows of a 6-column Nullable table. The three elements get
`disabled="1"` (texts and numbers 0-11 unchanged) and are appended after
the last query: verbatim over the two plain tables (`{plain_table}`, the
sub-second expansions the marker also stops) and over the two Nullable
tables (`{nullable_table}`) with `WHERE key % 2 = 0`, which keeps half of
every block. History numbers 14-25 are fresh; queries 12 and 13 are
untouched. No existing query number or text changes: 3 queries (12
numbered entries) are disabled and 6 (12 entries) are appended.

Local perf.py A/B on official MasterCI amd_release builds, 8 pinned cores:
- Size: the copies run at 0.49-0.55 of their originals (projected CI
  medians 550-690 ms amd, 566-702 ms arm); A/A noise not worse.
- Structure at 8 and 12 threads: the same PartialSortingTransform /
  MergeSortingTransform / MergingSortedTransform instance counts, half of
  the sorted rows (0.500), the same peak threads, the same EXPLAIN PLAN
  steps (the filter is a PREWHERE of the read step), the same number of
  read chunks (Memory 153, MergeTree 611-614).
- Sensitivity on the four MasterCI build pairs that moved these queries on
  CI by 11-18% (3a52fa3 -> 2f953ee and 562bdc1 -> 4f8c9f2 on the one-key
  sorts, 1b7e6cd -> ca1dbe5 and abd6a6d -> 8f53dd7 on the 3- and 5-key
  sorts): every copy moves like its original (e.g. 1b7e6cd -> ca1dbe5:
  originals 1.27-1.31x, copies 1.22-1.30x; abd6a6d -> 8f53dd7: 0.78x,
  0.77-0.81x), and on the other class's pairs the copies stay within
  the noise of their originals.

Saving: about 30 s (amd) / 31 s (arm) per master perf job.

Related: ClickHouse#129258

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; 2 findings; 1 full pass), plus my own review (2 nits on the PR text).

# Sev Finding Verdict Evidence / action
1 ⚠️ Disabling the three {table} queries also stops their plain expansions (0, 1, 4, 5, 8, 9), whose verbatim copies restart at new numbers; splitting each element into an enabled {plain_table} and a disabled {nullable_table} element would keep their history DISAGREE The series appends only and never changes an existing <query> (the rule agreed on #129366); the split changes three existing elements and inserts queries before query 12. The merged #129625 re-appends sub-second expansions verbatim the same way. The restart is stated in the description; the split is a small change if a reviewer prefers it.
2 ⚠️ Runtime evidence needed that the WHERE key % 2 = 0 copies keep the sort signal DISAGREE Measured with perf.py on official MasterCI amd builds: at 8 and 12 threads the copies run 8/8/1 and 12/12/1 sort processors, the same plan steps, the same read chunks (Memory 153, MergeTree 611-614) and 0.500 of the sorted rows; on the four MasterCI build pairs that moved these queries by 11-18% on CI, each copy moved like its original in both seat orders (e.g. 1.304x vs 1.294x, 0.781x vs 0.766x). arm was not run locally; this PR's arm perf comparison measures the copies.
3 💡 Title said "the six queries above 1 s", but query 13 is 1.22 s on amd AGREE, fixed Title and first sentence of the description reworded.
4 💡 Commit message ranges (690 / 702 ms) differ slightly from the measured 680 / 695 ms AGREE Noted, not blocking; the description carries the measured ranges.

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

Session id: cron:clickhouse-review-slot-8:20261115-061501

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? The cost is measured, not intermittent: MasterCI medians (54 commits) of queries 2, 3, 6, 7, 10, 11 are 1.10-1.25 s on amd and 1.13-1.28 s on arm, and 1.1-1.3 s locally on the official build.
b Root cause explained? Each sorts all 10M rows of a 6-column Nullable(UInt64) table with JIT off (compile_sort_description = 0 in the perf harness); the Nullable merge comparator is what puts them above their plain siblings (0.73-0.89 s).
c Fix matches root cause? One line per Nullable copy: WHERE key % 2 = 0, half of every block. Texts, keys, directions, SELECT * and FORMAT Null are unchanged; the originals stay in the file, disabled.
d Test intent preserved / new tests added? At 8 and 12 threads the copies run the same sort processors (8/8/1 and 12/12/1), the same plan steps and the same number of read blocks (Memory 153, MergeTree 611-614) with half of the sorted rows. On the four build pairs that moved these queries on CI, each copy moves like its original (one-key: 1.16-1.18x vs 1.14-1.18x, 0.87-0.88x vs 0.89x; 3- and 5-key: 1.27-1.31x vs 1.22-1.30x, 0.78x vs 0.77-0.81x). No new test: the file is the test.
e Both directions demonstrated? Every build pair ran twice, with the older build on the left and then on the right; the effect is the mean of both. The one-key pairs do not move the 3- and 5-key copies beyond their originals' noise, and the reverse.
f Fix is general across code paths? N/A (test-only). Memory and MergeTree, plain and Nullable, 1, 3 and 5 keys are all kept.
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A (test-only).
h Backward compatible? (maintainer-approved exception only) No existing query number or text changes; the copies get the new numbers 14-25 (CIDB has only 0-13 for this test).
i Invariants and contracts preserved? 14 queries stay enabled (a master job samples 10, as before); creates, fill and drop unchanged; no disabled query runs (query_log of both servers); no query's time grows run over run in the final file.

Session id: cron:clickhouse-impl-slot-41:20261115-011300

@clickhouse-gh

clickhouse-gh Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [f6decd6]

Summary: ❌

job_name test_name status info comment
Performance Comparison (arm_release, master_head, 3/6) ERROR

AI Review

Summary

PR #131761, reviewed at f6decd676031778c375d7130120a15714b91c7fb, reduces the six expensive nullable sorting benchmarks to half their rows, retains disabled originals for query numbering, and appends equivalent plain-table benchmarks. No actionable findings after reviewing the full diff, current code, harness behavior, and all prior discussion.

Missing context / blind spots
  • ⚠️ SQL benchmarks were not rerun locally. Runtime and regression-sensitivity conclusions rely on the author's documented measurements; local validation exercised the actual harness expansion code against the base and head XML.
Final Verdict

Status: ✅ Approve. No new inline comments are needed.

@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 15, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - f6decd6

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Performance Comparison (arm_release, master_head, 3/6) infra, not from this PR (jit_sort.xml is not in this shard's list): the job was killed by the 7200 s job timeout (Job timed out ... exit code [-15]) because test selection ran all 142 tests of the shard with --max-queries 0. It picked the 2026-11-15 NightlyCoverage cohort (79929b2c), which collected no coverage, so every test became mandatory. This shard errored on 13 PRs since 05:58Z #131772 (mine, open)
Mergeable Check, PR praktika rollups of the row above #131772 (the owner above)

The other CIDB FAIL rows on this head are Config Workflow / Pre Hooks of the runs before the can be tested label.

Session id: cron:our-pr-ci-monitor:20261115-093012

@clickhouse-gh clickhouse-gh Bot added comp-query-execution Runtime execution pipeline, processors, vectorized operators, resource management during execution. and removed comp-testing Test content only (no production code). labels Nov 20, 2026

This branch has not been deployed

No deployments
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-query-execution Runtime execution pipeline, processors, vectorized operators, resource management during execution. pr-ci

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant