Skip to content

perf(ivfpq): speed up transposed PQ8 scans - #76

Merged
jerry-024 merged 4 commits into
apache:mainfrom
jerry-024:perf/ivfpq-sparse-scan-quarter
Aug 13, 2026
Merged

perf(ivfpq): speed up transposed PQ8 scans#76
jerry-024 merged 4 commits into
apache:mainfrom
jerry-024:perf/ivfpq-sparse-scan-quarter

Conversation

@jerry-024

@jerry-024 jerry-024 commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Speed up transposed 8-bit IVF-PQ scans by exposing each 256-entry lookup table as a fixed-size array, allowing the compiler to eliminate bounds checks in the hot loop. Search results and the existing 12.5% sparse/dense crossover remain unchanged.

Changes

  • Add fixed-array fast paths for initializing and accumulating transposed PQ8 distances.
  • Keep the slice-based fallback for non-PQ8 lookup tables.
  • Cover scan results around the configured sparse/dense crossover.
  • Add a deterministic filter-scan benchmark using the production query shape (nq=64, nprobe=64).

Testing

  • cargo fmt --all --check
  • cargo check -p paimon-vindex-core --tests --target x86_64-unknown-linux-gnu
  • cargo clippy -p paimon-vindex-core --benches --target x86_64-unknown-linux-gnu -- -D warnings

Single-thread benchmark on the same SSH development host:

Filter density p50
6.25% 541.739 ms
12.5% 907.507 ms
18.75% 1058.931 ms
25% 1040.456 ms
50% 1071.382 ms
100% 1066.809 ms

Historical scalar results on the same host and shape were 1890.700 ms at 50% density and 1849.500 ms at 100%, directional improvements of 43.3% and 42.3%. These were not interleaved A/B runs; production impact still needs a Spark run on the target AMD executor.

Notes

  • No unsafe code, architecture-specific SIMD, index-format changes, or user-facing configuration are added.
  • Recall, filtering semantics, and the number of PQ codes evaluated are unchanged.

@jerry-024 jerry-024 changed the title perf(ivfpq): widen sparse scan crossover perf(ivfpq): eliminate PQ8 LUT bounds checks Aug 12, 2026
@jerry-024
jerry-024 force-pushed the perf/ivfpq-sparse-scan-quarter branch from cc8fde5 to c80295a Compare August 13, 2026 02:12
@jerry-024 jerry-024 changed the title perf(ivfpq): eliminate PQ8 LUT bounds checks perf(ivfpq): speed up transposed PQ8 scans Aug 13, 2026
Comment thread core/benches/ivfpq_filter_scan_bench.rs Outdated
fn main() {
assert_eq!((NQ, NPROBE), (64, 64), "benchmark production query shape");
assert!(
std::env::var_os("PAIMON_VINDEX_LOG_IVFPQ_TIMING").is_none(),

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.

This guard checks a stale environment variable name. The exercised search path currently reads PAIMON_VINDEX_LOG_IVFPQ_BATCH_TIMING and PAIMON_VINDEX_LOG_IVFPQ_BATCH_REUSE, so enabling either diagnostic still passes this assertion and can add instrumentation/logging overhead to the measured samples. Could we assert that both current variables are unset before running the benchmark?

@jerry-024
jerry-024 marked this pull request as ready for review August 13, 2026 07:05
@shyjsarah

Copy link
Copy Markdown
Contributor

+1

@jerry-024
jerry-024 merged commit f41224a into apache:main Aug 13, 2026
9 checks passed
@jerry-024
jerry-024 deleted the perf/ivfpq-sparse-scan-quarter branch August 13, 2026 07:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants