Skip to content

feat(search): calibrate recall targets by metric and k - #10695

Merged
BubbleCal merged 4 commits into
mainfrom
yang/adaptive-nprobes-recall-tiers
Nov 5, 2026
Merged

BubbleCal merged 4 commits into
mainfrom
yang/adaptive-nprobes-recall-tiers

Conversation

@BubbleCal

@BubbleCal BubbleCal commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

search_effort now has empirical mean partition-routing targets of 80% at 0.1 and 90% at 0.25. The probe budget adapts to metric and k, calibrated through k=100,000. The default 0.5 preserves the existing Auto budget and nominal 95% target.

The implementation uses 26 shared k anchors with separate fractions of Auto for L2, cosine and dot, interpolated geometrically in log(k). Explicit bounds, fixed-probe precedence, zero/one endpoints and late probing retain their behavior. There are no public signature or index-format changes. Hamming and k above 100,000 retain uncalibrated legacy behavior; 100,000 is the calibrated endpoint, not a new API limit.

Calibration uses DINO 10M, LAION 10M, FineWeb 10M, Wiki-Cohere 35M and DPR 21M, preserving their original calibration/held-out splits. Exact Float64 top-100000 oracles cover 31 k values per corpus. Coefficients and interpolation anchors are selected on calibration queries only, then frozen before evaluation.

Effort Routing target Held-out recall range Groups meeting target
0.1 80% mean 80.762%–88.600% 155 / 155
0.25 90% mean 90.674%–93.926% 155 / 155
0.5 (default) 95% mean 94.189%–99.510% 152 / 155

The unchanged default misses 95% on DINO k=1/10 and FineWeb k=1. These are routing objectives, not per-query or final Recall@k guarantees. Quantization, filtering, approximate routing and caller bounds can reduce final recall. The native sample also retains subset misses without retuning.

Native validation compares the preceding metric-wide policy at direct parent aff6f1d1a8df56dc72f6b3ab1498086e0688125c with measured implementation 8d5cb16ec558790537bcdb2e189ff96256e2247b. The parent binary was produced from daf655a75bd3cceedb38b5b198b7e2fd143a30b5; the intervening changes are verified to contain only reporting/docs. Final report changes preserve the measured product and query-driver code.

Representative same-effort measurements show both directions of the quality/cost tradeoff. Lower latency is better. The speedup below sacrifices excess recall to reach the lower requested target; it is not an equal-recall improvement.

Scenario / metric Baseline This PR Benefit Recall: baseline / PR
DINO FLAT, k=10001, effort=0.1; latency 199.683 ms 47.482 ms 4.21x speedup 96.374% / 81.362%
Wiki-Cohere FLAT, k=100000, effort=0.1; latency 498.262 ms 833.115 ms 1.67x slower 77.180% / 85.260%
DPR FLAT, k=100000, effort=0.1; latency 256.202 ms 388.861 ms 1.52x slower 69.409% / 80.830%

Both binaries use the same immutable S3 indices on one AWS r8i.8xlarge, Rust 1.98.1, release-with-debug, CPU affinity 0–15, Lance/Rayon 16 threads, BLAS/OMP 1 thread and 112 GiB index cache per worker. Recall uses 128 held-out queries; latency is the mean of per-query medians over three balanced passes on 64 queries. Queries are serial. Cold controls use 16 queries, fresh sessions and zero index cache. Full summaries retain regressions, default controls, CPU, read volume and operations; no unchanged-default speedup is claimed.

All 83,616 native query records across 366 groups passed independent returned-ID audits. Default IDs are identical across both binaries. Warm FLAT groups have zero reads in both arms. All five warm-FLAT subset misses and the DPR 16-query cold subset miss match frozen predictions on the same query IDs; no parameters were refitted. RQ5 k=1000 with refinement=2 stays near 0.99 s across all three tiers, with about 1,993 read operations per query. Lower routing cost does not remove this refinement cost. Full raw evidence and binaries are archived with verified SHA256 checksums.

Validation:

  • 1,197 Rust KNN tests, 91 Python API/integration tests and 11 calibration/oracle/harness tests passed. The per-k regression fails on the preceding metric-wide implementation.
  • Rust formatting, strict workspace Clippy, uv run make lint, Ruff and pre-commit passed. All four dependency lockfiles are unchanged.
  • All 156 Rust coefficients match the frozen calibration artifact. No held-out/native result was used to retune parameters.

Current measurements and limitations · Calibration and reproduction · Initial study

This establishes upstream implementation and bounded benchmark evidence. Release, automatic mirror synchronization and normal SDK/Sophon adoption remain separate acceptance stages.

@github-actions github-actions Bot added A-python Python bindings A-index Vector index, linalg, tokenizer A-java Java bindings + JNI A-docs Documentation enhancement New feature or request labels Nov 3, 2026
@BubbleCal
BubbleCal marked this pull request as ready for review November 4, 2026 04:12

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.

Tip: disable this comment in your organization's Code Review settings.

@BubbleCal
BubbleCal marked this pull request as draft November 4, 2026 04:22
@BubbleCal BubbleCal changed the title feat(search): calibrate lower recall targets for search effort feat(search): calibrate recall targets by metric and k Nov 4, 2026
@BubbleCal
BubbleCal marked this pull request as ready for review November 5, 2026 02:15

@lance-gatekeeper lance-gatekeeper Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Gate recommendation: approve with a non-blocking risk.

The per-k calibration addresses both under-routing at large k and excessive probing within wide Auto buckets. The default Auto path remains unchanged.

Existing effort settings below 0.5 change their quality/cost operating point. Large-k dot searches can become slower, while quantization, filtering and refinement can reduce final recall or dominate latency. Check final Recall@k and query cost on representative workloads when adopting these tiers; the routing targets remain empirical averages.

@lance-gatekeeper lance-gatekeeper Bot added K-approved Latest Gatekeeper recommendation permits acceptance. K-risk Latest Gatekeeper recommendation includes a non-blocking risk. labels Nov 5, 2026
@BubbleCal
BubbleCal merged commit 481f729 into main Nov 5, 2026
48 of 49 checks passed
@BubbleCal
BubbleCal deleted the yang/adaptive-nprobes-recall-tiers branch November 5, 2026 10:30
Xuanwo pushed a commit to lancedb/lancedb that referenced this pull request Nov 6, 2026
Downstream workspaces adopting Lance 15.0.0-beta.11 currently also
resolve beta.10 because the SDK pins every Lance crate exactly. This
produces incompatible Lance types across the SDK and the consumer.

Update the workspace pins and lockfile to the published
[v15.0.0-beta.11](https://github.com/lance-format/lance/releases/tag/v15.0.0-beta.11).
This release includes payload-free list length reads and preserves those
read modes across serialized plans (lance-format/lance#10759,
lance-format/lance#10766). Existing feature flags and unrelated locked
packages are unchanged.

The release also includes the metric/k-dependent search-effort
calibration from lance-format/lance#10695. Update the Node and Python
execution tests to its exact probe budgets (for example, effort 0.25
with L2, k=8 and Auto=6 now probes 4 partitions), and cover the 0.1
tier. Recall, caller bounds and probe-precedence assertions remain in
place.

Validation:
- `cargo fmt --all --check`
- `cargo clippy --quiet --features remote --tests --examples`
- Downstream metadata fixture with SDK source and the released Lance
beta.11 path overrides resolves exactly one Lance version.
- `cargo test --quiet --features remote --tests`: 2,271 passed, 0
failed, 79 existing ignored tests.

- Node native/TypeScript build, lint and API documentation generation
passed; 41 query tests passed.
- Python native binding build and package Ruff checks passed; 208 query
tests passed, 1 slow test deselected, 5 existing deprecation warnings.
- Rust results remain applicable: the follow-up changes only binding
tests, with product source and dependency graph unchanged from the
tested dependency update.

Repository-root Ruff currently reports 59 lint findings and 6 formatting
failures in untouched documentation snippets. Their blobs match the PR
base; the changed Python test and the entire Python package pass
lint/format checks.
BubbleCal added a commit to lancedb/lancedb that referenced this pull request Nov 6, 2026
Lance beta.11 calibrates lower `search_effort` tiers by metric and
requested `k`. With the Rust dependency and Python/Node execution tests
already on main via #4881, document the tiers across Rust, Python, Node
and the search guide, extend the remote request matrix to cover `0.1`
and `0.25`, and align the Python test package with beta.11.

`0.1` and `0.25` target empirical mean partition-routing recall of 80%
and 90% for L2, cosine and dot through `k=100000`. These are not
per-query or final Recall@k guarantees. Default Auto is unchanged;
Hamming and larger `k` remain uncalibrated, and remote queries require
corresponding server support. This PR makes no additional performance
claim. See [Lance
#10695](lance-format/lance#10695) for
measurements and limitations.

Validation: both strict workspace Clippy configurations, Rust
formatting, 13 Rust effort tests, 208 Python query tests, 41 Node query
tests, native binding builds, TypeScript, Node lint/generated docs,
Python lint/format, full lockfile check and two dependency guards passed
on `a8b09170`. All validated Rust/Python/Node source and dependency
files are byte-identical at `2a82d07c`; the only subsequent change
restores the Java POM to main. Root Ruff has 59 existing diagnostics and
six formatting files, all byte-identical to the base; the Python package
passes.

The Java REST/Namespace client has no changed API here, and its
dependency remains identical to main. The separate [Java beta
publication failure](lance-format/lance#10773)
is not claimed resolved or validated. Official SDK release, automatic
mirror, Sophon adoption and measured consumer acceptance remain
follow-up stages.
Xuanwo added a commit that referenced this pull request Nov 12, 2026
#10443)

## Summary

The shared-scan batch IVF node (`ANNIvfBatchExec`, #7640) required fixed
probe bounds (`minimum_nprobes == maximum_nprobes`). Adaptive requests,
including the default bounds and any explicit `search_effort`, fell back
to one indexed search per query. This PR applies the single-query
adaptive rules inside the batch node for IVF_FLAT, IVF_PQ, and IVF_SQ.
Partition loads stay shared across queries. There are no changes to the
index trait, the public API, or the index format.

#10480, now merged, scores each loaded chunk's queries on separate CPU
tasks. Before it, `search_partitions_batch` scored each chunk on a
single CPU task, so routing adaptive bounds to the shared node showed up
as a 3.3x slowdown on the existing `query_ann_batch` benchmark (768-d
IVF_PQ, `k = 100`). The scanner changes are in
`dataset/scanner/vector.rs`. `ANNIvfBatchExec` now lives in
`io/exec/knn/batch.rs` and its adaptive tests in
`dataset/tests/dataset_scanner_knn_adaptive.rs`, so no module grows past
the size check.

This follows up the min/max-nprobes question from the #7640 review. It
builds on the segment-ownership fix in #9638. With #9618, namespace
`multi_vector` requests that use adaptive bounds can now reach the
shared path.

## Commits

1. `perf(vector): support adaptive nprobes in shared-scan batch IVF
search` is the change itself.
2. `test(vector): move adaptive batch KNN tests into their own file`
moves tests without changing them.
3. `fix(vector): align batch late search with single-query skip and stop
rules` adds the selects-nothing skip, the budget-based ranking release,
and the late-search helpers shared with the single-query path.
4. `refactor(vector): move ANNIvfBatchExec into its own module` moves
code without changing it. Only imports and three intra-doc link paths
change.
5. `Merge origin/main into perf/batch-ivf-adaptive-nprobes` merges
`main` at `cd0a24899`; it had no conflicts.
6. `test(vector): cover hybrid scalar prefilter in adaptive batch KNN`
adds the #10001 producer regression.

## Execution

- Rank each query on the CPU runtime and apply the existing
`AutoProbePolicy`, including `search_effort`. This is the same policy
call the single-query path makes for each delta.
- Search every query's initial budget in one shared call per delta.
Finish the early phase for all deltas before deciding which queries need
late search.
- Keep only rankings that late search can still read. A query's ranking
is released once it holds `k` candidates, holds every row the prefilter
allows, or has no late range. Deltas with no remaining late work,
including fixed, exhausted, and empty-ownership deltas, are released
before the next delta is scanned. Retained deltas are checked again at
the early-search barrier.
- Run late search in rounds through the existing batch API, with one
virtual query per (query, partition) pair. Each query consumes its
partitions in rank order and stops where a sequential search would stop.
Rows after that cut are discarded.
- Admit whole queries per round, up to `max(1024, compute CPUs)` probes
**across all queries and deltas**. The first query rotates between
rounds so none starves. A query's deltas therefore advance together, and
its rows do not depend on the rest of the batch. A query whose own waves
exceed the cap is clipped and resumes at the first delta it could not
fully admit. Admitted deltas run concurrently, and their results are
consumed round-robin.
- Score each loaded chunk on up to one CPU task per compute CPU,
splitting its queries into contiguous ranges with at least 8 probes each
when the chunk has enough. This applies to fixed and adaptive batches.
- Apply segment ownership to early and late results and to the stopping
budgets. Segments that own nothing skip late work, and so do segments
whose own prefilter selects nothing. As in the single-query path
(#10485), the latter are counted once in `segments_skipped`. The
fewer-than-k shortcut returns only owned, unseen rows from eligible
segments.
- The single-query and batch late searches share the stop budget, the
fewer-than-k shortcut condition, and the segment-ownership check
(`LateSearchBudget`, `segment_owns_rows` in `knn.rs`), so the two paths
cannot drift on when a query stops.
- Keep the per-query fallback for explicit parallel adaptive probing
(`query_parallelism > 1` or `-1`) and for adaptive IVF_RQ. Neither is
equivalent to the shared sequential path today. Parallel late search can
admit partitions past the sequential cut. Multi-bit IVF_RQ prunes with a
probabilistic lower bound, so batch and single-query search can drop
different rows (#10778). Fixed-probe IVF_RQ keeps its existing shared
path and shows the same intermittent difference on `main`, independent
of this PR.

## Memory

- Per-query candidates stay in the bounded `TopHits` collector from
#9688, so retained candidates are `Q * k`. `TopHits` gains an `iter()`
so the fewer-than-k shortcut can skip rows it already holds.
- For Float32 vectors, the temporary key copies in a late round hold at
most `B * dim` floats, and a round returns at most `B * k` rows, where
`B` is the round cap. With the default cap, a round of 1024-d queries
copies at most 4 MiB of keys.
- Adaptive rankings cover every partition. They are released per query
once the query holds `k` candidates (or every row the prefilter allows)
or has no late range, so an unfiltered batch does not keep `Q *
num_partitions` ranking entries per delta after the delta's early scan.
While a delta is being ranked, all of its queries' rankings are held at
once.

These bound the round scratch, not total execution memory. Ranked plans
for genuine adaptive work, partition storage, and output have their own
costs. Measured peak memory is under [Peak memory and
latency](#peak-memory-and-latency).

## Behavioral scope

For a single delta, shared adaptive FLAT/PQ/SQ follows the same
sequential probe ranges and stopping rules as single-query search.
Equal-distance ties can select different valid rows. With multiple
deltas, results are consumed in a deterministic round-robin order rather
than by completion timing, so identical row sets are not promised. The
multi-delta tests check progression, uniqueness, counts, and recall. A
query's rows do not depend on the other queries in the batch unless its
own waves exceed the round cap.

Batched exact refinement (#9353) covers fixed nprobes. Exact refinement
with adaptive bounds keeps the per-query path, and
`test_batch_knn_indexed_refine`'s `adaptive` case asserts that.

**Metric change:** for adaptive batches that take the shared path,
`partitions_searched` counts the shared scan's partition loads, as the
fixed-probe batch path already does, instead of summing each query's
searches. This includes late-search partitions loaded in a wave past a
query's cut. Identical queries in one batch therefore count a partition
once. The Python `test_vector_search_effort` batch assertion is updated
to match. Adaptive IVF_RQ still reports the per-query sum.

## Tests

- IVF_FLAT, IVF_PQ, IVF_SQ: batch results equal per-query results on
single-delta fixtures. Cases cover unfiltered, selective, capped,
oversized-maximum, fewer-than-k, and empty-filter queries.
- `search_effort` at 0, 0.25, 0.75, and 1, with and without a filter:
rows and distances match single-query search. Forcing the batch planner
to ignore effort fails 18 of the 24 cases.
- IVF_RQ: adaptive cases assert the per-query fallback and compare rows
and distances with single-query search. Fixed-probe RQ still uses the
shared node.
- Distance ranges on IVF_FLAT and IVF_PQ, with and without a filter:
rows and distances match single-query search. Narrow ranges leave
queries short of `k` rows, so they exercise late search to exhaustion.
- Cosine and dot: results equal single-query search, and recall is at
least 0.5 against brute force, with and without filters.
- Late search: deterministic tests cover row cuts, delta progression,
ownership budgets, the fewer-than-k shortcut, and empty ownership. The
cut test is arranged so that a row past the cut would displace a
retained row from the bounded top-k if it were consumed.
- Batch independence: a two-delta case where the round cap falls between
a query's deltas returns the same rows as an uncapped query. Under
per-(query, delta) admission, that query returned a farther row.
- Round planning: cap and fairness tests cover partial waves, 1,025
queries, 129 deltas, and a cap of 1. A three-delta execution test
records the actual batch calls. It asserts that each round admits only
whole queries and never exceeds the cap.
- Lifetime: weak-reference tests show that rankings, keys, and index
handles for fixed and empty-ownership deltas are released before the
next early delta, while state needed for adaptive late search stays
alive. Rankings of queries that already hold `k` candidates are
released, including when a later delta completes the query. So are
rankings of queries that hold every row the prefilter allows.
- Chunk scoring: range splitting is tested for empty, small, even,
capped, skewed, and trailing-empty probe counts, and every query with
probes belongs to exactly one range. All batch-vs-single equality tests
run with the parallel scorer, including with `LANCE_CPU_THREADS=1`.
- A delta whose own prefilter selects nothing (the filter keeps only
rows of a newer delta): batch search reports the same `segments_skipped`
as single-query search and returns the same rows. A unit test checks
that such a delta does not join late search. Reverting the skip fails
both.
- `LateSearchBudget` and `segment_owns_rows`: unit tests cover allow
lists below, at, and above `k`, empty masks, and masks that cannot count
their rows (block lists, whole fragments).
- `query_parallelism` 0 and 1 take the shared path, and their rows and
distances match single-query search. Explicit parallel probing keeps the
per-query path.
- Existing HNSW, zero-probe, external-mask, overlay, and coverage
fallbacks are unchanged. #9353's `test_batch_knn_indexed_refine` still
requires exact refinement with adaptive bounds to take the per-query
path.

## Validation

The integrated head merges `main` at `cd0a24899` (#10753) into the
branch in `2f63075ad`. Git merged cleanly, and the result keeps #10001's
hybrid scalar prefilter producer, #10721's `lance_core::utils::tokio`
spawn boundary, and #10727's extracted `partition_search` scoring; no
old inline implementation was restored.

- `cargo test --profile ci -p lance --lib
dataset_scanner_knn_adaptive::`: 74 passed.
- `cargo test --profile ci -p lance --lib dataset_scanner_knn::`: 152
passed.
- `cargo test --profile ci -p lance --lib io::exec::knn::`: 1,219
passed, covering the batch, late-search, ownership, segment-contract,
and budget units.
- `cargo test --profile ci -p lance --lib
dataset_scanner_segments::test_hybrid_prefilter_consumers`: 12 passed,
so #10001's ANN, batch, and FTS consumers keep their union prefilter.
- `cargo test --profile ci -p lance --lib io::exec::prefilter_union::`
and `--test integration_tests prefilter_union`: 2 and 16 passed.
- `cargo test --profile ci -p lance-index --lib -- minhash`: 63 passed.
- `cargo clippy --profile ci --all --tests --benches -- -D warnings` and
`cargo fmt --all -- --check`: clean.
- Python `test_vector_index.py -k "search_effort or batch"` against a
native build of the integrated head: 68 passed.
- `uv run make lint` from `python/`: clean.

The integration adds `test_batch_knn_adaptive_hybrid_scalar_prefilter`,
which reaches the adaptive batch scan through #10001's
`PrefilterUnionExec`. An exact B-tree predicate on `i` (`i >= 250 AND i
< 1750`) covers both producer shapes: a scalar index over every fragment
while the scan selects the middle two (`scalar_fragments=2,
evaluated_fragments=2`), and a scalar index over two of four fragments
(`scalar_fragments=2, evaluated_fragments=4`). Each case asserts that
the union producer and `ANNIvfBatch` are planned and `ANNSubIndex` is
not, that per-query rows and distances equal single-query search, that
every returned row satisfies the predicate and stays inside the selected
fragments, and a recall floor of 0.5 against the flat oracle.

### Author-reported validation before integration

Recorded against `58e62bd54`, which includes #10695 (search-effort
calibration by metric and k) and #10761 (segment contract checks),
before this branch was merged with `main`:

- `cargo test -p lance --lib`: 10,075 passed, 0 failed, 9 ignored.
- Batch, adaptive, `search_effort`, range-splitting, and late-search
budget tests with `LANCE_CPU_THREADS=1` and
`LANCE_IVF_STREAMING_SEARCH_BATCH_SIZE=1`: 1,049 passed.
- `cargo test -p lance-index --lib -- minhash`: 63 passed.
- Python `test_vector_index.py -k "search_effort or batch"` on a fresh
`make build`: 68 passed.
- `cargo clippy --all --tests --benches -- -D warnings`, `cargo clippy
-p lance --all-features --tests -- -D warnings`, `cargo fmt --all --
--check`, and `RUSTDOCFLAGS="-D warnings" cargo doc -p lance --no-deps`:
clean. On aarch64 macOS, clippy also needs `-A unreachable_code` for the
NEON byte-stream-split code already on `main`.
- With the selects-nothing skip reverted, the end-to-end
`segments_skipped` test and the late-search unit test fail. With the
ranking release reverted to `k`, the budget retention test fails.
- Earlier, on `0db573921` before the rebase, the full Python suite
(`pytest python/tests -n auto`) passed 1,902 tests.

## Benchmark suite

Everything in this section and the next two is author-reported: it was
measured on the author's hardware against the revisions named below and
was not re-run on the integrated head.

`python/python/benchmarks/test_search.py` gains a `fixed` (`nprobes =
10`) and an `adaptive` (default bounds) case for the two
`query_ann_batch` benchmarks. These are pylance release builds of this
branch, measured before it was rebased onto `0db573921`, and of `main`
at `65df9b7c4`, run on one Apple M5 Max. The dataset has 100k x 768-d
vectors on local disk, IVF_PQ with 32 partitions, `k = 100`, and 32
queries. Values are pytest-benchmark medians in ms.

| Benchmark | `main` | This PR |
|---|---|---|
| `test_batch_ann_search[clean-adaptive]` | 10.20 | 6.14 |
| `test_batch_ann_search[clean-fixed]` | 12.68 | 4.53 |
| `test_batch_ann_search[with_delete_files-adaptive]` | 11.10 | 7.00 |
| `test_batch_ann_search[with_delete_files-fixed]` | 16.71 | 5.04 |
| `test_batch_ann_search[with_new_rows-adaptive]` | 57.75 | 55.78 |
| `test_batch_ann_search[with_new_rows-fixed]` | 53.80 | 50.15 |
| `test_repeated_single_ann_search[clean-adaptive]` | 46.66 | 46.01 |
| `test_repeated_single_ann_search[clean-fixed]` | 26.98 | 27.12 |

`with_new_rows` has unindexed fragments, so it keeps the per-query path.
The repeated single-query cases do not use the changed code and serve as
a noise reference. Without #10480, `clean-adaptive` took 33.67 ms.

## Peak memory and latency

This is a release-build measurement of this branch, taken before it was
rebased onto `0db573921`, and of `main` at `65df9b7c4`. It is not
checked in. The dataset is on local SSD: 500k x 16-d Float32 vectors,
IVF_FLAT with 2,048 partitions, either as one index segment or as four
(an initial index plus three appended deltas indexed with
`optimize_indices`). Queries are uniform random vectors drawn
independently of the data, with `k = 10` and the default adaptive
bounds. A batch of 256 queries has low partition overlap; 8,192 queries
puts the per-query rankings at about 134 MB per segment.

Each configuration runs in a fresh process. Peak growth is the process
high-water RSS (`getrusage` `ru_maxrss`) after the query minus its value
just before. Values are the median of 3 runs on one Apple M5 Max. On
`main`, an adaptive batch runs one indexed search per query inside the
same plan.

| Segments | Queries | Filter | Peak RSS growth (`main` → this PR) |
Latency (`main` → this PR) |
|---|---|---|---|---|
| 1 | 256 | none | 133 MB → 34 MB | 56 ms → 56 ms |
| 1 | 256 | `i % 97 = 0` | 507 MB → 36 MB | 128 ms → 58 ms |
| 1 | 8,192 | none | 2,172 MB → 208 MB | 2,150 ms → 297 ms |
| 1 | 8,192 | `i % 97 = 0` | 14,448 MB → 195 MB | 4,994 ms → 311 ms |
| 4 | 256 | none | 316 MB → 45 MB | 162 ms → 143 ms |
| 4 | 256 | `i % 97 = 0` | 677 MB → 46 MB | 236 ms → 149 ms |
| 4 | 8,192 | none | 5,716 MB → 226 MB | 3,693 ms → 1,023 ms |
| 4 | 8,192 | `i % 97 = 0` | 16,961 MB → 277 MB | 6,320 ms → 1,099 ms |

Both builds return the same number of rows in every configuration. On
`main`, the baseline already includes planning the per-query searches,
so its growth is understated. Object-store latency is measured
separately below.

## Object-store latency

This measures release builds of `main` at `56963cb29` and of this PR at
`58725f2fe`, through the Java binding on a Spark cluster in Azure: 8
executors with 4 cores each, data on Azure Data Lake Storage (ABFS). The
dataset has 10M x 1024-d embeddings in 10 fragments, with one IVF_PQ
segment: L2, 256 partitions, and 64 sub-vectors. Queries are dataset
rows with 5% Gaussian noise, `k = 10`, and the Java `Query` sets no
nprobes, so probing is adaptive from a minimum of 1 with no maximum.
Each of 32 Spark tasks sends its share of the queries as one batch call
(batch) or as one call per query (per-query). Values are the median wall
time of 5 runs after a warmup, with the best run in parentheses, in ms.
Each build ran in its own job on a shared cluster.

| Filter | Queries | `main` batch | This PR batch | Per-query (`main` /
this PR) |
|---|---|---|---|---|
| none | 1,000 | 1,204 (1,175) | 1,190 (1,172) | 1,360 / 1,309 |
| none | 4,000 | 4,370 (4,153) | 3,835 (3,758) | 4,586 / 4,190 |
| `rid % 20000 = 0` (500 rows) | 1,000 | 6,236 (6,091) | 1,294 (1,246) |
— |
| `rid % 20000 = 0` (500 rows) | 4,000 | 19,786 (19,510) | 3,469 (3,403)
| — |

- The per-query path does not change in this PR, so its column shows the
difference between jobs: 4–9%. Without a filter, the shared path is
within that range of `main`.
- With the filter, about 2 matching rows fall in each partition, so
queries need late search. The shared path is 4.8x faster at 1,000
queries and 5.7x faster at 4,000. Per-query search was not run with the
filter.
- Recall@10 against an exact ground truth (with the same filter) over
100 queries is the same for both builds: 0.726 without the filter and
0.553 with it. Without the filter, per-query and batch rows agree for
every recall query in both builds.

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Xuanwo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-docs Documentation A-index Vector index, linalg, tokenizer A-java Java bindings + JNI A-python Python bindings enhancement New feature or request K-approved Latest Gatekeeper recommendation permits acceptance. K-risk Latest Gatekeeper recommendation includes a non-blocking risk.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants