Repository navigation
Conversation
`firstNonDefault` made, for every row and argument, a virtual `isDefaultAt` call on the argument and a virtual `insertFrom` from the casted column. It computes every `USING` column of a `FULL JOIN`, so a filter on such a column after the join (`joins_in_memory` ClickHouse#19/ClickHouse#20) spent most of its CPU in that loop, and the cost of the indirect calls moved with code placement between builds. Now each argument's default rows are counted once with `getNumberOfDefaultRows`: an argument with no default rows decides every row and its casted column is returned without copying, and an argument that is default everywhere is skipped. For the first partially-default argument, `getIndicesOfNonDefaultRows` gives the rows it decides, which are copied as ranges (`insertFrom` for a run of one row); the per-row loop runs only over the later arguments, for the rows the first one leaves undecided. Same results for every input: the bulk methods agree with `isDefaultAt` for every column type (the only column without `getIndicesOfNonDefaultRows`, `ColumnAggregateFunction`, has no default rows). 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; 2 findings; bounded: 1 full pass + 1 fix round + 1 delta recheck).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-10:20261001-161400 |
|
Workflow [PR], commit [6193ff4] Summary: ✅
AI ReviewSummaryThis PR replaces the row-by-row Missing context / blind spots
Final Verdict✅ No blocking or major issues found. The new fast path preserves the existing contract that defaultness is checked on the original argument types, the added stateless coverage exercises the column families touched by the optimization, and the current CI report for PR LLVM Coverage ReportMeasured on commit 6193ff4.
Changed lines: Changed C/C++ lines covered: 39/39 (100.00%) · Uncovered code |
|
📊 Cloud Performance Report ✅ AI verdict: This PR only changes how firstNonDefault builds its result column (it now uses column-level default counts and copies runs of rows) and adds tests for it. Neither benchmark calls this function, so it cannot plausibly move either flagged ClickBench query. Q28 (+6.5%) is not_sure because the two tests disagreed and the timings were very noisy. Q34 (+5.9%) falls inside master's current range for that query, and CPU time barely moved on either one, so no action is needed. clickbenchFlagged queries (2 of 43)
Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on. tpch_adapted_1_official🟢 No significant changes Debug info
|
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units7 translation units recompiled, 7 s compile time in total, 7 of them have a recent master baseline. |
4cbdb04
Related: #118757
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Function
firstNonDefault, which computes theUSINGcolumns ofFULL JOIN, now copies whole ranges of rows instead of making two virtual calls per row. Queries that use aUSINGcolumn of aFULL JOINafter the join, for example inWHERE, are faster.Description
Requested in #118757 (comment):
joins_in_memory#19/#20 (FULL JOIN ... USING i64,i32,i16,i8 WHERE i32 = 20042) were +24.5% in Performance Comparison (arm_release, master_head, 1/6) on an unrelated PR.FULL JOIN ... USINGcomputes eachUSINGcolumn asfirstNonDefault(l.k, r.k), so thisWHEREevaluates it over every joined row (about 1.1e8). For each row it made a virtualisDefaultAtand a virtualinsertFromcall, about 40% of the query's CPU in the arm flamegraph, and the whole +24.5% of that run is inside this function. The cost of these calls varies between binaries: in 30 days of arm runs the reference side never exceeded 0.132 s, while the PR side exceeded 0.138 s 22 times across 15 unrelated PRs.Now the default rows of each argument are counted in bulk (
getNumberOfDefaultRows). An argument without default rows is returned without copying, and one that is default in every row is skipped. For the first partially-default argument,getIndicesOfNonDefaultRowsgives the rows it decides, which are copied as ranges; the per-row loop remains only for the rows it leaves undecided. Results and types are unchanged.x86, 16 pinned cores,
clickhouse local, medians of 5 interleaved rounds (base / fix):LEFT JOIN, nofirstNonDefault)I measured on x86 only; the arm effect can only be checked in this PR's Performance Comparison.
03522_function_first_non_defaultgets a 200000-row block checked againstmultiIf.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/123302]
Version info
26.10.1.1291-master(included in26.10and later)