Skip to content

HashJoin probe: rows==1 fast path - #106008

Merged
nickitat merged 5 commits into
masterfrom
vec-A4-rowref-iter
Jun 11, 2026
Merged

nickitat merged 5 commits into
masterfrom
vec-A4-rowref-iter

Conversation

@nickitat

@nickitat nickitat commented May 27, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

Version info

  • Merged into: 26.6.1.638

nickitat and others added 3 commits May 27, 2026 13:11
Two micro-optimizations to the probe-side row iteration:

1. `RowRefList::ForwardIterator::operator++` now issues
   `__builtin_prefetch(batch->next->next, 0, 0)` on each batch
   transition. With `Batch::MAX_SIZE == 7`, prefetching one batch
   ahead gives the line ~7 iterations of latency to land in L1
   before we chase the `next` pointer ourselves. Locality 0 is
   used because the prefetched line is touched once and then
   evicted (streaming pattern, no temporal reuse).

2. `addFoundRowAll`'s non-lazy branch in `KnownRowsHolder.h` now
   short-circuits the `rows == 1` case, mirroring the existing
   lazy-path special case on lines above. The single inline
   `RowRef` inside `RowRefList` is fed to `appendFromBlock`
   directly, avoiding `ForwardIterator` construction and the
   `first` branch on the hot single-match path of `ALL` joins.
@nickitat nickitat added the ci-performance performance only label May 27, 2026
@clickhouse-gh

clickhouse-gh Bot commented May 27, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [daf35d2]

Summary: ✅


AI Review

Summary

This PR adds a non-lazy HashJoin probe fast path for RowRefList with mapped.rows == 1, passing the inline RowRef directly instead of constructing ForwardIterator. I did not find correctness, safety, or performance-review blockers in the current diff; the prior performance-evidence thread is addressed by a completed Praktika run on the same src/Interpreters/HashJoin/KnownRowsHolder.h change.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-performance Pull request with some performance improvements label May 27, 2026
@nickitat nickitat removed the ci-performance performance only label May 27, 2026
subkanthi pushed a commit to subkanthi/ClickHouse that referenced this pull request May 28, 2026
`Summary.to_markdown` builds the PR comment as

    **Summary:** <symbol>
    - <name>: <links_md>
    ...
    |job_name|test_name|status|info|comment|
    |:--|:--|:-:|:--|:--|
    |[<job>](<url>)|...|

GitHub's markdown parser (and most CommonMark renderers) treats a `|...|`
line that comes directly after a `- ` list item as a continuation of the
list, so the failure table never builds — it just shows as a long string
of pipes inside the last bullet.

Insert an explicit blank line after the `extra_links` bullets so the
following section is parsed as its own block. Example PR
ClickHouse#106008 showed the broken
rendering — the `Performance Comparison: [Performance dashboard](...)`
bullet swallowed the entire `AST fuzzer` failure table.

Co-authored-by: Cursor <[email protected]>

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and reasonable, thank you!

@clickhouse-gh

clickhouse-gh Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.40% 84.40% +0.00%
Functions 92.40% 92.40% +0.00%
Branches 77.00% 77.00% +0.00%

Changed lines: Changed C/C++ lines covered by tests: 6/6 (100.00%) | Lost baseline coverage: none · Uncovered code

Full report · Diff report

@clickhouse-gh

clickhouse-gh Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

🔴 AI verdict: degradation — 1 query(s) regressed out of 39 analysed

This PR modifies the HashJoin row-collection path (addFoundRowAll), adding a single-row fast path. TPC-H Q4 leans heavily on that join path via its EXISTS semi-join, so the flagged +18.97% regression (3412ms vs 2868ms) is directly attributable to the change rather than noise. The delta is large and confirmed consistently by both tests, so it merits a look — verify the new single-row branch isn't adding overhead or mishandling the common multi-row case for this query.

clickbench

🟢 No significant changes

tpch_adapted_1_official

🔴 1 regressed

Flagged queries (1 of 22)
Query Verdict Baseline med (ms) PR med (ms) Change q-value Hint
🔴 4 regression 2868 3412 +19.0% 0.0005 join_operator: PR adds a single-row fast path in HashJoin addFoundRowAll; Q4's EXISTS semi-join exercises exactly this path

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.

Debug info
  • StressHouse run: 1fe2cad7-38da-4fa0-91f8-c453dbd78d1c
  • MIRAI run: 7f09002d-c921-46ce-aad6-4c14c2828761
  • PR check IDs:
    • clickbench_389535_1780582601
    • clickbench_389552_1780582601
    • clickbench_389560_1780582601
    • tpch_adapted_1_official_389566_1780582602
    • tpch_adapted_1_official_389571_1780582602
    • tpch_adapted_1_official_389636_1780582601

@nickitat nickitat added pr-not-for-changelog This PR should not be mentioned in the changelog and removed pr-performance Pull request with some performance improvements labels Jun 11, 2026
@nickitat
nickitat marked this pull request as ready for review June 11, 2026 10:30
@nickitat
nickitat added this pull request to the merge queue Jun 11, 2026
Merged via the queue into master with commit 26d36bf Jun 11, 2026
166 checks passed
@nickitat
nickitat deleted the vec-A4-rowref-iter branch June 11, 2026 10:45
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Jun 11, 2026
harikrishnan94 added a commit to harikrishnan94/ClickHouse that referenced this pull request Jun 12, 2026
The merge of `origin/master` auto-applied the single-row fast path of
PR ClickHouse#106008 into `addFoundRowAll`, but that optimization is written
against the pre-`BuildRef` `RowRefList` (it reads a `rows` field and
casts the head node to `RowRef`), neither of which exists on this
branch. It is also unnecessary here: a singleton lives inline in the
cell word and the iterator decodes it without touching the arena node,
which is exactly what the fast path was avoiding.

Co-Authored-By: Claude Fable 5 <[email protected]>
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
The merge of `origin/master` auto-applied the single-row fast path of
PR ClickHouse#106008 into `addFoundRowAll`, but that optimization is written
against the pre-`BuildRef` `RowRefList` (it reads a `rows` field and
casts the head node to `RowRef`), neither of which exists on this
branch. It is also unnecessary here: a singleton lives inline in the
cell word and the iterator decodes it without touching the arena node,
which is exactly what the fast path was avoiding.

Co-Authored-By: Claude Fable 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-not-for-changelog This PR should not be mentioned in the changelog 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