← Back to Pull requests

GH-50026: [C++][Parquet] SIMD-accelerate SBBF probe via branchless autovec #50030

Closed
unknown closed this pull request without merging on Jun 18, 2026 14:45 UTC
View on GitHub
unknown unknown commented on May 24, 2026 15:55 UTC
Author

Rationale for this change



BlockSplitBloomFilter::FindHash ships the scalar reference probe — an 8-iteration short-circuit loop. The short-circuit blocks autovectorization, and on miss-heavy workloads (Parquet row-group skipping) the per-lane branch-mispredict dominates probe latency.

Closes #50026. Dev list discussion: https://lists.apache.org/thread/omof0fq47tndfd80g5hwp2bvjmzvpb40. Sibling change in Rust: apache/arrow-rs#10011.

### What changes are included in this PR?

- Rewrite FindHash as a branchless OR-accumulator reduction. The new shape autovectorizes to SSE on x86 and NEON on aarch64 at the baseline.
- Add bloom_filter_avx2.cc (xsimd kernel built with -mavx2) behind CpuInfo-based DynamicDispatch, mirroring the existing level_comparison_avx2 pattern. xsimd was a requirement from the dev thread; the AVX2 target spells the reduction explicitly with xsimd::batch<uint32_t, xsimd::avx2> (pinned so an AVX-512 baseline build can't widen the batch to 16 lanes and over-read the 32-byte block) because gcc/MSVC don't lower the autovec body to a single vptest.
- No on-disk format change, no public API change, and bit-identical to the scalar reference.
- Insert path uses the same loop shape and will land in a follow-up PR.

### Performance

End-to-end FindHash via parquet/benches/bloom_filter_benchmark.cc.

M1 (Apple clang -O3, NEON via autovec, 10 reps, CV ≤ 0.4%):

| Bench | upstream/main | this PR | Speedup |
|---|---:|---:|---:|
| BM_FindExistingHash (hit-heavy) | 3.85 ns/probe | 2.41 ns/probe | 1.60× |
| BM_FindNonExistingHash (miss-heavy) | 9.04 ns/probe | 2.41 ns/probe | 3.75× |

x86-64 (gcc 13.3, -O2 -mavx2 via AVX2 dispatch TU, 5 reps, CV ≤ 0.6%):

| Bench | upstream/main | this PR | Speedup |
|---|---:|---:|---:|
| BM_FindExistingHash (hit-heavy) | 8.62 ns/probe | 4.32 ns/probe | 2.00× |
| BM_FindNonExistingHash (miss-heavy) | 15.29 ns/probe | 4.33 ns/probe | 3.53× |

The scalar miss path stalls on the data-dependent early-exit (slower than its own hit path on both archs); the branchless reduction is constant-time across hit/miss. InsertHash, BatchInsertHash, ComputeHash, BatchComputeHash all unchanged (16 benches within ±0.6%, inside CV).

Cache regime sweep: scalar vs xsimd, post-hash probe latency:

| Regime | scalar | xsimd | Speedup |
|---|---:|---:|---:|
| Small in-cache (0.5 MiB) | 12.35 ns | 2.48 ns | 5.0× |
| Medium out-of-L3 (128 MiB) | 18.40 ns | 7.41 ns | 2.5× |
| Large deep DRAM (1 GiB) | 31.05 ns | 22.10 ns | 1.4× |

Branchless body alone (no xsimd kernel) on AVX2:
- on clang -mavx2 it's within noise of the hand-written xsimd kernel in every regime
- on gcc it matches except ~0.79× of xsimd in the out-of-L3 regime.
- That gap is why this PR ships a separate xsimd kernel for the AVX2 TU rather than relying on autovec alone — on clang-only builds the xsimd kernel is essentially a no-op but on gcc/MSVC it pins the vptest lowering.

### Are these changes tested?

Yes. New BloomFilterProbeKernel test calls both dispatch targets directly across 20K random blocks + 200 production-populated blocks per CI run, asserting bit-identical output. DynamicDispatch resolves once at static init, so without this
test the un-picked target would never be exercised in CI.

Existing BasicTest, FPPTest, and CompatibilityTest continue to pass on both the scalar baseline and the AVX2 dispatch path.

### Are there any user-facing changes?

No. Read-path implementation change only.

  • GitHub Issue: #50026
  • Diff: 458 lines (+343 / -115) across 5 files Reviewer: dmatth1 Review duration: 35930m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.46) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.46 · 458 lines diff across 5 files
    0.46
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.367
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #50030"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 45.5% (MEDIUM) · Higher = larger blast radius
    45.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 18.0% · Safe to merge
    18.0%
    Repository