Repository navigation
Conversation
…Y loops The six `limit_by_*` pause failpoints and the four cancellation `LOG_TEST` lines were added for `tests/integration/test_limit_by_transform_kill_query` (ClickHouse#106070). That test was removed in ClickHouse#123165, so nothing uses them anymore. The `isCancelled` checks themselves stay. They are not free in a release build: ThinLTO inlines the in-loop `LOG_TEST` block (with `currentThreadHasGroup`) and the mid-loop failpoint into `LimitByTransform::consumeImpl`, and the size of that cold code decides where the per-row loop lands inside the function. ClickHouse#125738 makes `currentThreadHasGroup` smaller, which moves the loop 0x60 bytes earlier with the same instructions; on the CI amd runners `limit_by #0` and `optimize_limit_by_keys #0/ClickHouse#1` were 13-43% slower in all three builds of that PR, and in none of 26 other recent builds. Without the scaffolding the loop contains no logging, `CurrentThread` or failpoint code, and each row does one compare and branch less (`row_idx == 5`). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 0 findings) plus my own cold review (3 nits).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-9:20261021-120600 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-4:20261021-101000 |
|
cc @nihalzp @nickitat, could you review this and add the |
|
Workflow [PR], commit [0a42c28] Summary: ❌
AI ReviewSummaryRemoves six unused failpoints and four test-only cancellation log statements from the hash-based and sorted-stream Missing context / blind spots
Final VerdictStatus: ✅ Approve. No code changes requested. |
|
Closing: this change puts the |
Related: #125738 (comment)
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
LIMIT BYis slightly faster: its per-row and per-run loops no longer contain unused test-only logging and failpoint checks, so they run fewer instructions and their speed no longer depends on how unrelated logging code is compiled.Description
limit_by #0is red on #125738 in Performance Comparison (amd_release, master_head, 4/6) (+28%), andoptimize_limit_by_keys #0/#1, which run the same function, are 21-43% slower on all three amd builds of that PR. That PR does not touch LIMIT BY.The per-row loop of
LimitByTransform::consumeImplcontained test-only code: aLOG_TESTin the cancel branch and arow_idx == 5failpoint. In the ThinLTO build the inlinedLOG_TESTblock (which callscurrentThreadHasGroup) is placed before the loop body, so its size decides where the loop lands. #125738 makescurrentThreadHasGroupsmaller, and the loop moves 0x60 bytes earlier (same instructions, different alignment padding). The 26 other amd builds of the last 12 days have the old placement and are not slower, and the red job's CPU profile differs only in this function.The six
limit_by_*failpoints and four cancellation log lines were added in #106070 fortest_limit_by_transform_kill_query, which #123165 removed, so nothing uses them. This PR deletes them from both LIMIT BY transforms and fromFailPoint.cpp. TheisCancelledchecks stay.Validation: in a ThinLTO release build with CI's flags, the function is now byte-identical with and without #125738's
CurrentThreadchange, and the per-row loop runs 4 fewer instructions. Without this PR the loop moves exactly as in CI. Local release A/B (Granite Rapids, where the CI slowdown itself does not reproduce), median of 60-300 runs:limit_by #00.94x,optimize_limit_by_keys #0/#10.93x/0.95x,limit_by #1/#40.89x/0.90x, the other LIMIT BY perf queries unchanged within noise. The 71limit_bystateless tests give the same results as on master.Workflow [PR]
Sync PR [sync-upstream/pr/127172]