Skip to content

perf(ivfpq): eliminate PQ8 LUT bounds checks - #76

Draft
jerry-024 wants to merge 6 commits into
apache:mainfrom
jerry-024:perf/ivfpq-sparse-scan-quarter
Draft

perf(ivfpq): eliminate PQ8 LUT bounds checks#76
jerry-024 wants to merge 6 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 the transposed 8-bit IVF-PQ scan by exposing each 256-entry PQ lookup table as a fixed-size array, allowing the compiler to eliminate bounds checks in the hot loop. The sparse/dense crossover remains unchanged at divisor 8 (12.5%), and search results are unchanged.

Depends on #75. After #75 merges, the effective diff for this PR starts at 1357928.

Changes

  • Add a fixed [f32; 256] fast path for transposed PQ8 distance accumulation.
  • Keep the existing slice-based fallback for non-PQ8 tables.
  • Keep TRANSPOSED_SPARSE_SCAN_DIVISOR = 8.
  • Update the filter-scan benchmark to use the production query shape (nq=64, nprobe=64) and deterministic randomized filtering.
  • Cover the configured sparse/dense boundary and both fixed-array scan paths.

Testing

  • cargo fmt --all -- --check
  • cargo test -p paimon-vindex-core --lib (450 passed)
  • cargo clippy -p paimon-vindex-core --lib --benches -- -D warnings
  • Single-thread benchmark on the same SSH dev host with divisor 8 and the PQ8 optimization:
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 from the same host and shape were 1890.700 ms at 50% and 1849.500 ms at 100%, corresponding to directional improvements of 43.3% and 42.3%. These runs were not interleaved A/B measurements; production impact still requires a Spark run on the target AMD executor.

Notes

  • No unsafe code, architecture-specific SIMD, index-format change, or user-facing configuration is added.
  • This PR does not change recall, filtering semantics, or the number of PQ codes evaluated.

@jerry-024 jerry-024 changed the title perf(ivfpq): widen sparse scan crossover perf(ivfpq): eliminate PQ8 LUT bounds checks Aug 12, 2026
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.

1 participant