Repository navigation
fix(#10072): a native image uses scalar vector math instead of the uncompiled Vector API - #10077
Conversation
…compiled Vector API A GraalVM native image does not compile jdk.incubator.vector calls into SIMD instructions: each call runs the incubator's pure-Java lane loops, several times slower than plain scalar code. jvector still picked its PanamaVectorizationProvider there, so the graph build of 20k 384-dimension vectors took 178 s instead of 6.5 s. VectorApiSupport detects a native image. LocalDatabase's class init points jvector at its scalar provider before any jvector class resolves one, unless the user set jvector.vectorization_provider. The Graph-OLAP and time-series SIMD providers pick their scalar ops in a native image too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
|
This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again. |
ReviewFocused fix with a clear measurement table. The 1. Native-image init timing (main risk, already listed as pending)
2. Ordering assumption
3. Minor
4. Tests
No security concerns and no new dependencies. Once the native end-to-end result is confirmed (point 1), this looks good to me. |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 21 |
🟢 Coverage 95.00% diff coverage · -5.05% coverage variation
Metric Results Coverage variation ✅ -5.05% coverage variation Diff coverage ✅ 95.00% diff coverage Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (6b1f278) 236685 204627 86.46% Head commit (bc21089) 269411 (+32726) 219309 (+14682) 81.40% (-5.05%) Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch:
<coverage of head commit> - <coverage of common ancestor commit>Diff coverage details
Coverable lines Covered lines Diff coverage Pull request (#10077) 40 38 95.00% Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified:
<covered lines added or modified>/<coverable lines added or modified> * 100%
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
…upport The LocalDatabase hook only worked while LocalDatabase initialized before the first jvector provider lookup. VectorApiSupport.jvectorProvider() now applies the native-image rule in a lazy holder before it resolves jvector's provider, and all seven ArcadeDB call sites use it, so none of them can resolve the provider first. Adds tests for the configureJVectorProvider() side effect, and documents why -Xint is not probed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Review addressed in bc21089. 1. Native-image init timing - checked, the build-time path does not apply. 2. Ordering assumption - fixed. 3. 4. Untested side effect - added Engine vector, sparse-vector, time-series and Graph-OLAP suites: 3027 tests, 0 failures. |
ReviewThe approach is sound. It's small, the explicit Main concern: the pending native check
Minor points
Overall this looks good once the native benchmark confirms the ordering. |
|
Native end-to-end check (review point 1): passed. Native image built from this branch at bc21089 (GraalVM CE 25.0.2, macOS aarch64), started without
The |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #10077 +/- ##
=========================================
Coverage 78.32% 78.32%
Complexity 4538 4538
=========================================
Files 2235 2237 +2
Lines 236685 236710 +25
Branches 51237 51239 +2
=========================================
+ Hits 185384 185410 +26
+ Misses 32098 32094 -4
- Partials 19203 19206 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…compiled Vector API (#10077) * fix(#10072): a native image uses scalar vector math instead of the uncompiled Vector API A GraalVM native image does not compile jdk.incubator.vector calls into SIMD instructions: each call runs the incubator's pure-Java lane loops, several times slower than plain scalar code. jvector still picked its PanamaVectorizationProvider there, so the graph build of 20k 384-dimension vectors took 178 s instead of 6.5 s. VectorApiSupport detects a native image. LocalDatabase's class init points jvector at its scalar provider before any jvector class resolves one, unless the user set jvector.vectorization_provider. The Graph-OLAP and time-series SIMD providers pick their scalar ops in a native image too. The LocalDatabase hook only worked while LocalDatabase initialized before the first jvector provider lookup. VectorApiSupport.jvectorProvider() now applies the native-image rule in a lazy holder before it resolves jvector's provider, and all seven ArcadeDB call sites use it, so none of them can resolve the provider first. Adds tests for the configureJVectorProvider() side effect, and documents why -Xint is not probed. (cherry picked from commit ac89255)
Closes #10072
Problem
A GraalVM native image does not compile
jdk.incubator.vectorcalls into SIMD instructions. Each call runs the incubator's pure-Java lane loops, which are several times slower than plain scalar code. jvector still pickedPanamaVectorizationProviderin the native binary:Measured on macOS aarch64, 20k vectors x 384 dims, COSINE,
vector.neighborsk=10:-Djvector.vectorization_provider=defaultFix
VectorApiSupport(engineutility): detects a native image throughorg.graalvm.nativeimage.imagecode, and decides whether jvector must be forced to its scalar provider.LocalDatabase's static initializer callsVectorApiSupport.configureJVectorProvider(). jvector resolves its provider once per process, on first use, and every vector index and vector function needs aLocalDatabasefirst, so the property is set before jvector reads it. An explicit-Djvector.vectorization_provider=...still wins.GraphOlapVectorOpsProviderandTimeSeriesVectorOpsProvidernow choose through aselect(boolean)method and use their scalar ops in a native image. On a JVM the selection is unchanged.Completeness
Invariant: in a native image, no ArcadeDB code path runs the Vector API.
LSMVectorIndex,ArcadePageVectorValues,VectorUtils,SQLFunctionVectorAvg,JVectorUtils, jvector internals)defaultbefore first resolutionSimdGraphOlapVectorOpsviaGraphOlapVectorOpsProviderSimdTimeSeriesVectorOpsviaTimeSeriesVectorOpsProviderTests
VectorApiSupportTest(new, 4 tests): native without a choice ->default; an explicit provider wins; the JVM keeps jvector's own choice; the test JVM is not detected as native.GraphOlapVectorOpsTest/TimeSeriesVectorOpsTest:select(false)returns the scalar ops,select(true)the SIMD ops.benchmarkandslowexcluded): 2806 pass. The one failure,Issue9621SealedStoreChannelReopenTest.readersInterruptedMidScanAllGetTheirRows(ClosedChannelExceptionfrom an interrupted reader), is a known flake unrelated to this change, and passed 5/5 when run alone.Residual risk
-Djvector.vectorization_provider, builds the 20k-vector graph in 5.7 s (was 178.3 s) and answersneighborsin 3.6 ms median (was 13.7 ms). Details in the PR comments.🤖 Generated with Claude Code
Summary by CodeRabbit