← Back to Pull requests

dotProduct: handle slices exactly one vector wide without the non-inlined dotProductPreferred #816

Closed
unknown closed this pull request without merging on Nov 25, 2026 18:11 UTC
View on GitHub
unknown unknown commented on Nov 20, 2026 23:25 UTC
Author

Fixes #815.

What

PanamaVectorUtilSupport.dotProduct(v1, off1, v2, off2, length) now checks for a slice exactly one preferred vector wide first and calls dotPreferred directly. Previously it called dotProductPreferred, a 421-byte method that C2 does not inline ("hot method too big" in -XX:+PrintInlining), and only checked the exact fit inside it. dotPreferred is the same function the old route reached, so results are bit-identical. Five lines.

Results

JDK 26, macOS arm64 (Apple M4 Max), Panama provider, minimum over many rounds.

4-float dotProduct per call: 1.65 ns before, 0.61 ns after (squareDistance: 0.60 ns, unchanged).

Per-query PQ table build (precomputedScoreFunctionFor):

| dimension / subspaces | metric | main | this branch |
|---|---|---|---|
| 1024 / 256 | COSINE | 281 us | 24 us |
| 1024 / 256 | DOT_PRODUCT | 167 us | 24 us |
| 1024 / 256 | EUCLIDEAN | 24.5 us | 24.8 us |
| 1536 / 384 | COSINE | 421 us | 31 us |
| 768 / 192 | COSINE | 212 us | 18 us |
| 128 / 32 | COSINE | 35.5 us | 2.8 us |

End to end, fused-PQ cosine search from disk (30,000 x 1024-d, single thread, k=10, rerankK=100; two runs each, each building its own graph): 1,719 and 1,727 qps on main, 2,653 and 2,609 here (about +52%); p50 0.568 and 0.568 ms before, 0.366 and 0.373 ms after. Recall@10 was 0.9950 and 0.9917 before and 0.9940 and 0.9890 after, which is build-to-build variation (the kernel result is bit-identical).

x86 (Panama, AVX-512; Ice Lake and GNR; JDK 22 and 25): with 16-float subvectors the 1024-dim table build drops from 97 to 30 µs (Ice Lake, JDK 25), and single-thread PQ search on a 1M, 128-dim dataset gains about 12% with identical recall. Full-vector dot products (64 to 384 dims), 4- and 8-float subvector tables, and a full-precision graph build are unchanged within run-to-run noise, checked against an identical copy of main.

Tests

  • testDotProductOnShortSlicesWithOffsets compares dotProduct with the scalar provider for lengths 1 to 33 around the SIMD widths, at several offsets, including a slice exactly as wide as one preferred vector.

  • The earlier testDotProductFastPathMatchesPreferredBitwise was dropped: the new path and dotProductPreferred run the same dotPreferred, so it could not fail, and comparing raw bits failed once on Windows JDK 20 over a NaN sign bit.
  • Run on this branch, all passing: TestVectorizationProvider, TestProductQuantization and the PQ tests on JDK 22 and 25, with the native and Panama providers, at 512- and 256-bit vector widths.

    Known limits

  • On x86 the fast path applies only when a subvector is exactly one vector wide (8 floats on AVX2, 16 on AVX-512); a 4-float slice already takes the dotProduct128 branch and is unaffected. The native provider doesn't use this path.

  • A follow-up PR will make dotProductPreferred small enough to inline at every width, which makes this check redundant.
  • Diff: 365 lines (+273 / -92) across 4 files Reviewer: MarkWolters Review duration: 6885m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.43) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.43 · 365 lines diff across 4 files
    0.43
    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%
    56%
    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.353
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #816"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% 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: 42.7% (MEDIUM) · Higher = larger blast radius
    42.7%
    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: 56.8% · Lower = rushed or shallow review
    56.8%
    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.5% · Safe to merge
    18.5%