Skip to content

perf(index): share translated views for whole RaBitQ scoring - #10677

Merged
BubbleCal merged 2 commits into
mainfrom
yang/lazy-rq-shared-views
Nov 3, 2026
Merged

BubbleCal merged 2 commits into
mainfrom
yang/lazy-rq-shared-views

Conversation

@BubbleCal

@BubbleCal BubbleCal commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Native RaBitQ Full/Accurate scoring with the Planes cache layout now combines the translated sign/address view used by sparse reads with immutable whole ex planes, avoiding full-partition address remapping and code repacking. File offsets, tombstones, filtering, refinement budgets, full-bit scoring and phase timers are preserved. Partition layouts retain their ordinary reader so preparation consumes the same entries as prewarm; Fast and unsupported encodings also retain their existing readers. Public method signatures and the on-disk format are unchanged.

Targets main after #10642 merged as b4ad45c29f91ed4612f712584d1bf84322c530dd. Current head: 5dbf7b3924e998f734d8c97c1ce904d91dcd8824. This is the whole-scoring slice of OSS-2844; companion consumer routing is lancedb/sophon#9631.

Validation at 5dbf7b3924e998f734d8c97c1ce904d91dcd8824: the prewarm reproducer failed on parent 2298c5bb36f4844d5631cab3baf08f8402586ab5 with 34,888 extra bytes after prewarm, while the ordinary reader read zero. Both Partition and Planes regression cases now read zero additional bytes and preserve exact results and recall >= 0.5. All 64 native scan cases passed in 0.67 seconds, including v0/tagged FRI, cold and prewarmed dense queries, filters, refinement and cache lifecycle coverage. Test strategies explicitly select Planes for the shared-view cases, matching enabled Sophon LazyQuery. Formatting, full workspace Clippy with warnings denied, and commit hooks passed.

The retained performance evidence below measures the original paired Lance + Sophon source graph, not the isolated benefit of this PR. No S3 benchmark was rerun for the cache-layout fix; the original measured heads are listed below. This is not a new-head or production performance claim.

Scenario / metric Measured baseline Measured source pair Observed benefit
FRI c8, common first 1,024 queries, mean latency (lower is better) 672.07 ms 138.86 ms 4.84x speedup

Coyo: 15,380,795 rows × 2,048 float32 dimensions, native RQ7 cosine, 4,096 partitions, k=100, fixed nprobes=64, snapshots 2→4 with the same index/model. The S3 fixture was s3://mmlb-us-east-1/lazy-rq-cache-validation/t031-20261103/coyo-frozen.lance/, index UUID 489f5190-d049-476e-b51e-d77ceecfb2b2. Runs used c7i.8xlarge, eight fixed physical cores, 350 GiB gp3 at 8,000 IOPS / 1,000 MiB/s, and 7,006,754,887 bytes each for RAM and disk cache. Rust 1.97.1, release-with-debug; 32 warm queries; prewarm and snapshot checkout excluded. The index mirror was disabled for warm and timed queries.

One process per arm, at least 60 seconds and one frozen 1,024-query cycle, then drain; no confidence interval. Whole windows completed 1,024 / 3,999 queries at 11.88 / 66.36 queries/s. Different repeat counts make that QPS ratio unsuitable as the matched benefit. All 5,023 results matched Full reference row IDs and distance bits; unique-query recall@100 was 0.97376953125. The candidate retained 168,803 resident probes, and address-view hits + loader misses covered all 255,936 probes.

End charged cache was 6,998,555,318 → 6,986,044,894 bytes; end RSS was 8,791,830,528 → 8,545,579,008 bytes; lifetime HWM was 9,721,434,112 → 9,618,374,656 bytes and includes initialization. These are separate observations, not a general steady-state memory claim. The earlier cache-only c8 1.17x slowdown remains historical evidence; this targeted result does not complete integrated acceptance.

Exact source and artifact provenance
  • Lance direct parent e75d3685fa2259633cb0b178b19caefec623d867 → 3e8578b6589a3fd90f2791c0a5a1bbd53e1feb8b.
  • Sophon rabit_scan direct parent 0314932b2c19694adbdf2388aa7680ec6d35f18a → 7da85323facecc9d71d83758dacd250319575d78.
  • The experimental consumer graph used Sophon 12ccd06400b49c226ac3a92c2906141fb9664007 from the existing #9381, LanceDB d5013459eb4c7beb84d80bc2c26720d58f347611, the stated Lance source, and only the stated Sophon rabit_scan subtree overlay. This is not a production dependency upgrade.
  • Cargo.lock SHA256: 4a51717d183fc2d82e90c66af808cf5a6e6c8bb32e76c78409823af3b41bd1a6.
  • Harness SHA256: 7fb017d6620c1c0e18638cb96ff09ab1641d131f377cb01d35e8da7862a035ad.
  • Baseline ELF SHA256: 7ff0a05ccfdd9f2623899937551b29490ec240a7425e8e5a476d92de9c661443.
  • Candidate ELF SHA256: d28e30267949753720032f24d0d224bcbdf32438a39d4b1cac279c0c3bf794f4.
  • The 44-file c8-implementation-evidence.tar.gz archive has SHA256 86ce4a89513f7a8d57a457070de17b533ef3b5063ba55ed941a32692f19e3f1c. Source/build proofs, results, logs and preserved binary receipts are in the coordinator delivery package.

The coordinator will recheck current-head feedback, approval and CI before merge. Released upstream → internal-fork sync → separate compatible Sophon dependency adoption, and OSS-2845 / T-027 integrated acceptance remain separate gates. The seven missing-dependency assertions in the companion remain intact.

Base automatically changed from yang/lazy-rq-cache-identity to main November 3, 2026 10:42
@BubbleCal
BubbleCal force-pushed the yang/lazy-rq-shared-views branch from 3e8578b to 2298c5b Compare November 3, 2026 10:48
@BubbleCal
BubbleCal marked this pull request as ready for review November 3, 2026 11:02

@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.

@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 translated sign/address view and immutable ex plane preserve full-scoring behavior in the FRI, filter, and refinement cases. Adoption should align prewarm with the selected cache representation.

The reported speedup covers the original paired consumer graph. It does not establish an isolated or production benefit; retain integrated concurrency and memory validation before consumer rollout.

partition_id: usize,
dist_q_c: f32,
) -> Result<RabitPreparedPartition> {
if self.storage().supports_candidate_reads()

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.

The default RabitCacheLayout::Partition prewarm no longer warms this preparation path: Index::prewarm() fills whole-partition entries, while this branch reads sign/ex plane keys. In the four-fragment, 256-row fixture, the ordinary loader read 0 bytes after prewarm, but whole scoring read another 34,888 bytes. This is a non-blocking warm-up cost for strategies that retain the default layout.

Selecting Planes for a strategy using this path aligns its prewarm and scoring reads. Alternatively, retain the ordinary reader when the selected layout is Partition.

Executed reproducer

Add this test to native_scan_tests.rs and run cargo test -p lance --lib test_gate_whole_scoring_reuses_partition_prewarm. The first zero-read assertion passes; the final assertion fails with left: 34888, right: 0.

#[tokio::test]
async fn test_gate_whole_scoring_reuses_partition_prewarm() {
    struct IoMetrics(lance_io::scheduler::IoStats);
    impl lance_index::metrics::MetricsCollector for IoMetrics {
        fn record_parts_loaded(&self, _: usize) {}
        fn record_index_loads(&self, _: usize) {}
        fn record_comparisons(&self, _: usize) {}
        fn io_stats(&self) -> Option<lance_io::scheduler::IoStats> {
            Some(self.0.clone())
        }
    }
    let dir = TempStrDir::default();
    let (dataset, batch) = native_fixture(dir.as_str()).await;
    let uuid = dataset.load_indices().await.unwrap()[0].uuid;
    let configured = open_with_session(
        dir.as_str(),
        Session::default().with_rabit_scan_factory(Arc::new(NativeScanFactory::Whole)),
    ).await;
    let index = configured.open_vector_index("vector", &uuid, &NoOpMetricsCollector).await.unwrap();
    assert!(!lazy_index(&index).uses_rabit_plane_cache());
    index.prewarm().await.unwrap();
    let query = lazy_test_query(batch["vector"].as_fixed_size_list().value(0), 8, 4);
    let (partitions, distances) = index.find_partitions(&query).unwrap();
    let io = lance_io::scheduler::IoStats::new();
    for &partition in partitions.values() {
        lazy_index(&index).load_query_partition(partition as usize, &IoMetrics(io.clone())).await.unwrap();
    }
    assert_eq!(io.snapshot().bytes_read, 0, "ordinary reader consumes prewarmed cache");
    index.clone().search_partitions(
        query, Arc::new(partitions), Arc::new(distances), 0, 4,
        Arc::new(NoFilter), None, Arc::new(IoMetrics(io.clone())),
    ).await.unwrap().try_collect::<Vec<_>>().await.unwrap();
    assert_eq!(io.snapshot().bytes_read, 0, "whole scoring should reuse prewarmed cache");
}

@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 3, 2026
@lance-gatekeeper lance-gatekeeper Bot removed K-approved Latest Gatekeeper recommendation permits acceptance. K-risk Latest Gatekeeper recommendation includes a non-blocking risk. labels Nov 3, 2026
@BubbleCal
BubbleCal merged commit dd0b05e into main Nov 3, 2026
57 of 59 checks passed
@BubbleCal
BubbleCal deleted the yang/lazy-rq-shared-views branch November 3, 2026 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants