Repository navigation
Conversation
Contributor
|
Before you submit for review:
If you did not complete any of these, then please explain below. |
r-devulap
reviewed
Nov 28, 2026
…e call Code pairs score from padded codebooks or a centroid-pair table; tables are counted in PQVectors.ramBytesUsed().
Each kernel does its job in one body, takes no vectors and states a vector's exact class where a store needs it.
New C kernels and bindings; argument checks are overflow-safe.
No-boxing and parity tests, allocation probe, kernel benchmarks, release notes; ASH docs recommend the native provider.
tlwillke
marked this pull request as ready for review
November 28, 2026 07:00
tlwillke
requested review from
MarkWolters,
ashkrisk,
dian-lun-lin,
jshook and
vasimuddinmd
as code owners
November 28, 2026 07:00
Contributor
|
Here are results of BenchYAML (on disk, immutable graph index construction) results and it addresses the regression caused by #836
|
r-devulap
reviewed
Nov 28, 2026
r-devulap
left a comment
Contributor
There was a problem hiding this comment.
The part that fixes the #836 regression with a hybrid approach looks good to me, but the PR does much more than that, and I haven't yet reviewed the other performance changes it brings. I wonder if we should split it into multiple PRs. Right now it does too many things (PQ index builds, a rewrite of the Panama kernels, and new ASH kernels), which makes it hard to review and hard to bisect if something regresses.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes #845 (native PQ builds about 1.8x slower since #836).
The regression in #845 and the Panama "slow mode" have the same root: vector work split into many small calls. Natively, each subspace of a PQ code pair was its own call. In Panama, a value that crosses a call C2 doesn't inline is put on the heap, so the same build or search ran up to about 2x slower in one JVM than in the next. This PR does each job in one call, with the native and Panama providers sharing one design: the same entry points, layouts and thresholds, with only the language of the inner loop differing.
Themes
1. PQ code pairs in one call (the #845 fix). Both providers score a PQ code pair from a copy of the codebooks padded with zeros, so odd and mixed subspace widths run like even ones: one native call per pair, or one allocation-free Java loop. Subspaces of 16 floats or more use a centroid-pair table, kept with the PQ vectors being built and counted in their
ramBytesUsed(), so a model shared with searchers does not hold it. Saved and in-progress codes both use it.2. One call per job. PQ query tables are built in one call per query from transposed codebooks, with the query centered inside the kernel, on both providers. ASH on Panama gets the same treatment that native has: whole fused neighborhoods (nibble codes and INT8 field blocks), all rows of a symmetric comparison, and a whole batch of queued query projections in one call each, plus INT8 and FP16 query projection on request.
3. No Panama slow mode. Panama kernels are written so C2 keeps their vectors in registers however a JVM compiles them: each body does its whole job and is compiled on its own (above the 325-bytecode inline limit), never takes or returns a vector, names its species directly, calls
lanewiseat its own call sites (the JDK'sfma/addwrappers share one type profile across all callers), and states a vector's exact class where a store or reduction needs it. Without that, C2 guessed the class from a profile and in some JVMs lost it for one accumulator, so the PQ query table boxed in about one JVM in four.4. Guards.
PanamaNoBoxingTestchecks that no Panama method takes or returns vectors and that the bulk bodies stay above the inline limit; an opt-inPanamaAllocationProbe(-Djvector.test.allocationProbe=true) measures bytes per operation from callers 0-10 deep, alone or after every other case (-Dprobe.mixed=true);PanamaNativeParityTestchecks the new Panama paths against independent oracles and, where the library is loaded, against native.Results
On-disk PQ graph builds, Ice Lake (32 cores), JDK 22, graph insertion time in seconds, one fresh JVM per value (degree 32, beam 100, overflow 1.2, hierarchy, refinement, k=256, FP32 rerank). Recall@10 matched across builds.
Against main, builds are 1.2-2.9x faster with Panama and 1.4-3.1x faster with native. #833's 441.9 s run was in the slow mode (2,029 young GCs). Two native first runs of this PR were outliers (24.1 s and 35.7 s) and are replaced by their first alternating rerun. These builds predate the final review fixes, which change no arithmetic.
ASH with Panama, mpnet 1M, 2-bit codes, GNR (48 cores), JDK 22, mean of 3 fresh query JVMs (warm index, cold queries):
The native provider remains faster for ASH, and the docs now recommend it: with the same build, Panama reached 60-65% of native's QPS on OpenAI 3072 1M (2-bit, 1 and 8 cores).
Known limits
Tests
Full
jvector-nativeandjvector-testssuites on Ice Lake (8 cores), JDK 22 and JDK 25, native and Panama providers, compared with main on the same machine: no new failures. The remaining failures also fail on main (provider-selection tests that see the harness'sJDK_JAVA_OPTIONS, and JDK 25 Panama ASH tests that fail at random). After the review fixes, the PQ, ASH, parity and guard tests (243) ran again on JDK 22 and 25 with both providers: no new failures. The allocation probe ran every case in four fresh JVMs: every PQ query-table and code-pair case allocated nothing in every JVM. Parity tests also ran on GNR (48 cores).Release note
docs/release notes/4.1.0-rc.2/850.performance.md