Skip to content

Run the Int128 and UInt256 array_sort_numeric performance queries on a quarter of their rows - #132174

Merged
murphy-4o merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/perf-array-sort-numeric-quarter-rows
Nov 17, 2026
Merged

murphy-4o merged 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/perf-array-sort-numeric-quarter-rows

Conversation

@groeneai

@groeneai groeneai commented Nov 16, 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 arraySort and arrayReverseSort queries of array_sort_numeric.xml over Int128 and UInt256 (entries 5, 6, 15, 16) take 1.49-2.43 s on MasterCI amd and 1.18-1.50 s on arm. Each sorts 2M arrays of 32 16- or 32-byte elements single-threaded, through the typed fast path of #109832.

No existing query number or text changes: 2 queries (20 numbered entries) are disabled and 4 (20 entries) appended, as 26-45. The marker covers all ten {type} expansions, so its 16 sub-second ones return verbatim through {narrow_type}; the wide ones run through {wide_type} on numbers(500000): the same 32-element array blocks, 8 instead of 31. Per row the copies take 0.97-1.01 of the originals' user time, with the same sort share. Each run also pays a fixed 20-60 ms to fault its block in after the harness's jemalloc purge, as on MasterCI, so a copy keeps 0.90-0.95 of a per-row change and moves 3.7 times more than its original if that fixed cost changes.

#117346 (clang 23) moved the UInt256 sort by 0.878 on amd and 0.913 on arm MasterCI. Locally, in two repetitions on different NUMA nodes, its copy moved 0.922 / 0.916, the original 0.911 / 0.916; #120808 moves the Int128 reverse sort by 1.045 / 1.046, its copy by 1.051 / 1.044. Per-row numbers with L3 capped to 30 MiB.

The Decimal128 query (entry 22, 1.60 s amd) stays: its copy kept under half of #120808's effect in one of four passes.

Projected copy medians: 0.40-0.66 s amd, 0.31-0.41 s arm; about 21 s (amd) and 15 s (arm) less query time per master perf job. They restart the history of these 20 entries.

Validation: on the final file perf.py runs only entries 20-45 (also with --max-queries 10), no run trend.

🤖 Generated with Claude Code


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

Version info

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

…arter of their rows

No existing query number or text changes: 2 queries (20 numbered entries) are disabled and 4 (20
entries) appended, as 26-45. The two `{type}` queries get `disabled="1"`, which stops all ten of
their expansions; the 16 sub-second ones (master's 0-4, 7-14, 17-19) are appended verbatim through
a new `{narrow_type}` substitution, the four over Int128 and UInt256 (master's 5, 6, 15, 16: 1.49-2.43 s
on MasterCI amd, 1.18-1.50 s on arm) through `{wide_type}` on numbers(500000) instead of 2000000.

Each of the four sorts 2M arrays of 32 16- or 32-byte elements on one thread through the typed fast
path of ClickHouse#109832; user time is linear in rows. The copies keep the same 65409-row blocks (8 instead of
31) and the same per-block work. Every run also pays a fixed fault-in of its block after perf.py's
jemalloc purge, as on MasterCI.

Measured with perf.py on the official MasterCI amd builds, 8 pinned cores, two repetitions on
different NUMA nodes (per-row gates with the L3 capped to 30 MiB, 20 runs per server):
- per-row user time copy / original 0.969-1.006; user-time sort share within 0.016;
- kept fraction of a per-row change 0.897-0.950 (fixed part 21-59 ms per run);
- ClickHouse#117346 (clang 23; MasterCI 0.878 amd / 0.913 arm on the UInt256 sort): original 0.911 / 0.916,
  copy 0.922 / 0.916; ClickHouse#120808 on the Int128 reverse sort: original 1.045 / 1.046, copy 1.051 / 1.044.

The Decimal128 query (entry 22) stays enabled: its copy kept under half of ClickHouse#120808's effect in one
of four pass measurements (0.42).

Projected copy medians 0.40-0.66 s amd, 0.31-0.41 s arm: about 21 s (amd) and 15 s (arm) less query
time 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; 1 finding), plus my own review (2 findings, both on the PR text, fixed in the description before publication).

# Sev Finding Verdict Evidence / action
1 💡 The new XML comment writes Int128 and UInt256 without inline code noted Valid per the repository's comment style; a comment-only nit in a test file, not blocking.
2 💡 Entries 0-19 end their history; the copies (26-45) start new ones noted The disabled + append shape of the #129258 series; stated in the description.

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

Session id: cron:clickhouse-review-slot-9:20261116-230101

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? The cost is deterministic: entries 5, 6, 15, 16 take 1.52-2.54 s in every local perf.py pass on the official master build (CI medians 1.49-2.43 s amd), their copies 0.41-0.68 s.
b Root cause explained? Each sorts 2M arrays of 32 Int128 / UInt256 elements on one thread through the typed fast path of #109832 (sortNumericValues); the wide comparisons cost 16 / 23 ns per element vs 5.5 ns for UInt64. No fallback, time linear in rows, plus a fixed per-run fault-in of one block after the harness's jemalloc purge (also on MasterCI).
c Fix matches root cause? Test-only: the input size is the cost, so the copies run the same per-row path on a quarter of the rows. The two {type} queries are disabled, not changed.
d Test intent preserved / new tests added? Same path: the same 65409-row blocks of 32-element arrays (8 instead of 31), the same functions per block and the same per-block memory; per-row user time 0.97-1.01 of the originals', sort share within 0.016. The 16 sub-second expansions run verbatim. The Decimal128 query stays (its copy did not keep #120808's effect in one of four passes).
e Both directions demonstrated? Master's file runs entries 0-25, the final file 20-45 and never 0-19 (also with --max-queries 10). On two real build pairs the copies move like the originals: #117346 0.922 / 0.916 vs 0.911 / 0.916 (CI 0.878 amd, 0.913 arm), #120808 1.051 / 1.044 vs 1.045 / 1.046, in two repetitions on different NUMA nodes.
f Fix is general across code paths? Every type and both directions of the file still run, through the same sortNumericValues path; only the row count of the four wide copies changes.
g Fix generalizes across inputs (params/datatypes/wrappers)? N/A (performance test change); the types, array length and value generation are unchanged.
h Backward compatible? (maintainer-approved exception only) No setting, format, perf.py or CI change; entries 26-45 are fresh history keys (highest ever recorded: 25), 0-19 end their series.
i Invariants and contracts preserved? Entries 0-25 keep their text and number (perf.py --print-queries identical), the {type} substitution is unchanged, the copies follow the last query, no settings, create or fill added; 26 enabled entries before and after.

Session id: cron:clickhouse-impl-slot-7:20261116-214600

@clickhouse-gh

clickhouse-gh Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [a286a97]

Summary: ✅


AI Review

Summary

Reduces the four Int128 and UInt256 arraySort and arrayReverseSort performance workloads to 500,000 rows while retaining the other workloads and reserving existing query indices. No actionable findings. Focused validation of the actual harness expansion and sampling logic passed; runtime and sensitivity measurements were supplied in the PR and were not independently rerun.

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 16, 2026
@murphy-4o
murphy-4o added this pull request to the merge queue Nov 17, 2026
Merged via the queue into ClickHouse:master with commit d0e9ef9 Nov 17, 2026
571 of 573 checks passed
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 17, 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