Skip to content

Use a hashed sparse mask in the short_circuit_compact_logical_masks performance test - #124417

Merged
egor-click merged 1 commit into
ClickHouse:masterfrom
groeneai:stabilize-short-circuit-compact-masks-perf
Oct 11, 2026
Merged

egor-click merged 1 commit into
ClickHouse:masterfrom
groeneai:stabilize-short-circuit-compact-masks-perf

Conversation

@groeneai

@groeneai groeneai commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #123788

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 required: CI-only change.

Description

short_circuit_compact_logical_masks #0 and #1 (the sparse and/or masks, number % 64) take one of two times on arm on the same code. On #123788 the dashboard scored #0 +21% as a confirmed regression (arm 5/6 report): old 28.8-29.1 ms in 7 of 7 runs, new 33.2-35.3 ms in 6 of 7. On the previous head of that PR, the master server was the slow one.

Runs moving >10% old vs new since #120520 added the test (2026-09-26):

#0 #1 #2..#7
arm 264/3575 271/3559 2-4/3630
arm, master 35/460 29/455 1/465
amd 6/1133 5/1132 2-4/1133

#6/#7 run the same mask loop (extractMaskNumericImpl) with an 8-row period, and #4/#5 with a dense 64-row mask; both are stable, so the noise comes with the sparse 64-row period, not with the loop.

I changed #0 and #1 to select rows by intHash32(number) % 64: still 1/64 of the rows, still the compact short-circuit path this test was added for, but no period. Not intHash64: cityHash64 of an integer is intHash64, so it would decide the second argument. About half of the selected rows still reach the third argument (78276 / 77901 for #0 / #1).

Validation (x86, master build): perf.py runs all 8 queries cleanly. With short_circuit_function_evaluation = 'force_enable', a throwIf on unselected rows in the second argument passes (it throws Code: 395 with 'disable'), and a throwIf on selected rows in the third argument throws, so it is still reached. Medians of 30 interleaved rounds, 2 servers: #0 23.5-23.8 -> 26.6-26.7 ms, #1 23.9-24.1 -> 26.9-27.2 ms. I cannot measure arm locally; only the arm master census after merge can confirm the new form is stable.

🤖 Generated with Claude Code


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

Version info

  • Merged into: 26.10.1.2160-master (included in 26.10 and later)

…erformance test

Queries #0 and ClickHouse#1 selected every 64th row (`number % 64`). On arm their
timing is bimodal per server process: in CIDB, 264 / 271 of ~3570 arm runs
since the test was added moved more than 10% old-vs-new, while the six
other queries of the same test moved in 2-4 runs and amd in 5-6 runs.
Queries ClickHouse#6 / ClickHouse#7 run the same `extractMaskNumericImpl` instantiations with an
8-row period, and ClickHouse#4 / ClickHouse#5 with a dense 64-row mask, and are stable, so the
noise depends on the 64-row period of a sparse mask, not on the cost of the
mask loop.

Select the sparse rows by `intHash32(number) % 64` instead: the density
stays 1/64 and the queries still take the compact short-circuit path the
test was added for, but the mask has no period. `cityHash64` of an integer
is `intHash64`, so the selector uses a different hash to stay independent
of the other two arguments: about half of the selected rows still reach
the third argument, as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai groeneai added can be tested Allows running workflows for external contributors groeneai-origin-request PR origin: a maintainer pinged or directed groeneai labels Oct 7, 2026
@groeneai

groeneai commented Oct 7, 2026

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 rounds) plus my own review.

# Sev Finding Verdict Evidence / action
1 ❌ intHash64(number) % 64 decided bitAnd(cityHash64(number), 1) (integer cityHash64 is IntHash64Impl), so #0 never reached argument 3 and #1 sent every sparse row there AGREE, fixed selector is intHash32(number) % 64; 78276 / 77901 rows reach argument 3, a throwIf there throws under force_enable
2 ⚠️ No arm measurement of the new query shape DISAGREE no arm hardware available to me; the description makes no arm-stability claim; the arm perf shard and the post-merge master census are the evidence
3 💡 "noise comes with the 64-row period" also matched the stable dense #4/#5 AGREE, fixed scoped to the sparse masks

Second round: 0 findings. Severity: ❌ blocker / ⚠️ major / 💡 nit.

Session id: cron:clickhouse-review-slot-8:20261007-113501

@clickhouse-gh

clickhouse-gh Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [5239998]

Summary: ✅


AI Review

Summary

This PR updates the sparse queries in tests/performance/short_circuit_compact_logical_masks.xml:12 and tests/performance/short_circuit_compact_logical_masks.xml:13 to select rows with intHash32(number) % 64 instead of an exact 64-row period. That keeps the and/or compact-mask path exercised while removing the alignment pattern that made the arm timings bimodal. I did not find a correctness or CI-safety issue in the current patch.

Missing context / blind spots
  • ⚠️ The stated benefit is improved arm stability, but the PR's performance jobs are skipped and I do not have a local clickhouse binary or arm machine here, so I could not independently confirm the new selector on arm. An arm performance run or post-merge master census on the new query shape would close that gap.
Final Verdict

✅ Acceptable as-is. No inline findings.

@groeneai
groeneai requested a review from egor-click October 7, 2026 11:55
@clickhouse-gh clickhouse-gh Bot added the pr-ci label Oct 7, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-testing Test content only (no production code). label Oct 7, 2026
@egor-click
egor-click enabled auto-merge October 8, 2026 11:39
@egor-click
egor-click added this pull request to the merge queue Oct 11, 2026
Merged via the queue into ClickHouse:master with commit 48d2d6f Oct 11, 2026
152 checks passed
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 11, 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... groeneai-origin-request PR origin: a maintainer pinged or directed groeneai 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