← Back to Pull requests

Add the missing highway kernels #753

Closed
unknown closed this pull request without merging on Oct 15, 2026 20:20 UTC
View on GitHub
unknown unknown commented on Oct 13, 2026 01:59 UTC
Author

Implemented native C++ Google Highway SIMD kernels for: min_f32, sum_f32, scale_f32, and sub_f32/sub_scalar_f32 in jvector_simd_kernels.cpp, eliminating Panama Java Vector API fallbacks for them. These kernels vectorize horizontal reductions, in-place scaling, out-of-place subtraction, and 64-bit population count across all x86-64 (SSE4.2 to AVX-512) and AArch64 (NEON, SVE, SVE2) tiers, and are wired to NativeVectorUtilSupport.java through critical Java FFM bindings with unit tests in test_elementwise.cpp and release symbol verification in verify_native_lib.sh.

Kernel-level speedup using JDK 22.0.2

Measured at PR head efcf8ca8 over the pre-PR Panama baseline (598ef09e). Above 1× favors native; dimensions count floats.

| Dimensions | Alignment | Minimum | Sum | Scale | Vector sub | Scalar sub |
|---:|---:|---:|---:|---:|---:|---:|
| 64 | 0 B | 2.57× | 2.36× | 1.45× | 1.74× | 1.83× |
| 64 | 16 B | 2.62× | 2.27× | 1.05× | 1.54× | 1.73× |
| 768 | 0 B | 2.33× | 1.98× | 1.17× | 1.38× | 1.37× |
| 768 | 16 B | 2.35× | 1.64× | 1.77× | 1.15× | 1.11× |
| 1536 | 0 B | 2.41× | 1.35× | 1.09× | 1.19× | 1.20× |
| 1536 | 16 B | 2.41× | 1.33× | 1.85× | 1.10× | 0.99× |
| 3072 | 0 B | 2.47× | 0.91׆ | 1.02× | 1.08× | 1.08× |
| 3072 | 16 B | 2.47× | 1.19× | 1.87× | 1.08× | 1.06× |

Xeon 6985P-C, AVX-512, JMH 1.37; two forks, three 500 ms warmup and measurement iterations, one pinned thread, preallocated buffers, zero measured collections. Measurement began after idle checks, with no background-load interference detected. Alignment denotes address offset within a 64-byte cache line.

Native timings include the critical FFM call and exclude public-wrapper allocation and validation. Baseline subtraction output allocation is also excluded.

Native has lower mean times in 38 of 40 comparisons. Scalar subtraction at 1,536 floats / 16 B is approximately 1% slower; several other gains are marginal.

† Aligned 3,072-float native sum varied substantially between forks: 106.7 versus 168.0 ns/op. Its aggregate 0.91× result needs a focused repeat before drawing a performance conclusion.

Hamming is omitted because its native kernel was removed from this PR.

Kernel-level speedup using JDK 25

| Dimensions | Alignment | Minimum | Sum | Scale | Vector sub | Scalar sub |
|---:|---:|---:|---:|---:|---:|---:|
| 64 | 0 B | 2.47× | 1.65× | 1.47× | 2.06× | 2.03× |
| 64 | 16 B | 2.45× | 1.71× | 1.52× | 1.84× | 1.88× |
| 768 | 0 B | 1.74× | 1.64× | 1.22× | 1.37× | 1.46× |
| 768 | 16 B | 1.77× | 1.39× | 1.62× | 1.18× | 1.14× |
| 1536 | 0 B | 1.80× | 1.24× | 1.08× | 1.16× | 1.20× |
| 1536 | 16 B | 1.82× | 1.23× | 1.92× | 1.06× | 1.04× |
| 3072 | 0 B | 1.83× | 1.05× | 1.01× | 1.13× | 1.09× |
| 3072 | 16 B | 1.84× | 1.05× | 1.87× | 1.05× | 1.00× |

Temurin JDK 25.0.4.1. The native library is identical to the JDK 22 run.

Native has lower mean times in 40 of 40 comparisons. Results near 1× are marginal or effectively parity. The 768-float / 16 B scale baseline and 1,536-float / 16 B native scalar subtraction showed fork variation; the latter comparison is inconclusive. Aligned 3,072-float sum was consistent across forks at 101.78 ns/op native versus 106.77 ns/op Panama (1.05×).

Commits Breakdown

  • 7661442f: Added kernel declarations in jvector_simd_kernel_list.h and Highway SIMD implementations in jvector_simd_kernels.cpp.
  • 89bca21b: Added GoogleTest suites covering boundary and tail matrix sizes (1 to 255 elements) for all new kernels in test_elementwise.cpp.
  • 368d9499: Regenerated jextract Java FFM bindings with Linker.Option.critical(true) downcall handles in NativeSimdOps.java.
  • bf6288d0: Added all newly exported kernel symbols to REQUIRED_SYMBOLS in verify_native_lib.sh.
  • 77adbf62: Connected Java calls in NativeVectorUtilSupport.java to invoke NativeSimdOps for both off-heap MemorySegment` buffers and on-heap arrays.
  • Diff: 495 lines (+371 / -124) across 6 files Reviewer: tlwillke Review duration: 3980m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.47) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.47 · 495 lines diff across 6 files
    0.47
    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.371
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #753"
    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: 47.4% (MEDIUM) · Higher = larger blast radius
    47.4%
    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: 20.5% · Safe to merge
    20.5%