Skip to content

Prefetch join hash table bucket - #1390

Open
IsaacWarren wants to merge 2 commits into
mainfrom
isaac/join_prefetch
Open

Prefetch join hash table bucket#1390
IsaacWarren wants to merge 2 commits into
mainfrom
isaac/join_prefetch

Conversation

@IsaacWarren

@IsaacWarren IsaacWarren commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds a prefetch_bucket method to the vendored ankerl hash map that issues a read-only __builtin_prefetch for the bucket cache line find() will touch
  • Adds a software-prefetch pass to all 4 join probe loops: while probing row i, the bucket line for row i + D (D=16, tunable via BODO_JOIN_PROBE_PREFETCH_DIST) is prefetched, hiding part of the dependent cache-miss chain that dominates ht_probe_time
  • Hoists three per-row pin-guard resolutions in produce_probe_output out of the loop (resolved once per batch, passed as raw pointers)

The join probe hot loop is a pointer chase: hash -> bucket line -> entry/key line. Hardware prefetchers cannot help (non-stride). ht_probe_time was ~30% of the probe stage, the largest join-side timer.

Performance findings

All benchmarks: 8 workers, TPC-H SF10, interleaved A/B rounds, stage metrics from BODO_TRACING_OUTPUT_DIR (wall-clock medians; medians of 3 runs for the microbench).

Pure join microbenchmark (lineitem 60M x orders 15M int keys)

prefetch distance ht_probe_time / rank-exec delta
off 0.457 / 0.443s -
8 0.319 / 0.299s -31%
16 (default) 0.304 / 0.293s -34%
32 0.303 / 0.303s -33%

Probe stage total -13%.

Full TPC-H SF10, all 22 queries

metric off on (D=16) delta
wall, sum of per-query best 92.74s 82.98s -10.5%
ht_probe_time 0.347s 0.218s -37%
probe stage total 1.017s 0.835s -18%

@IsaacWarren IsaacWarren changed the title Prefetch join hash table bucket lines in the probe hot loop Prefetch join hash table bucket Sep 8, 2026
@IsaacWarren
IsaacWarren marked this pull request as ready for review September 8, 2026 17:22
@codecov

codecov Bot commented Sep 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.16%. Comparing base (0f7e335) to head (9cb0fd3).
⚠️ Report is 31 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1390      +/-   ##
==========================================
+ Coverage   66.55%   68.16%   +1.61%     
==========================================
  Files         198      198              
  Lines       68731    68961     +230     
  Branches     9834     9905      +71     
==========================================
+ Hits        45744    47009    +1265     
+ Misses      20071    19077     -994     
+ Partials     2916     2875      -41     

@DrTodd13 DrTodd13 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM. thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants