You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@paimon.apache.org by "jerry-024 (via GitHub)" <gi...@apache.org> on 2026/08/12 04:27:54 UTC
[PR] perf(ivfpq): widen sparse scan crossover [paimon-vector-index]
jerry-024 opened a new pull request, #76:
URL: https://github.com/apache/paimon-vector-index/pull/76
## Summary
Use the sparse transposed 8-bit IVF-PQ scan path for filter densities up to 25% instead of 12.5%. Local x86 benchmarks show this avoids unnecessary dense scans at the 18.75% and 25% crossover points.
Depends on #75. Review the final optimization diff from commit `1357928` to `4eeea12`; once #75 merges, this PR diff will contain only that change.
## Changes
- Change the transposed sparse-scan divisor from 8 to 4.
- Cover the new 25% boundary and adjacent filtered-scan cases.
- Add a deterministic 8-bit IVF-PQ filter-density benchmark.
## Testing
- [x] `cargo fmt --all -- --check`
- [x] `cargo test -p paimon-vindex-core` on x86_64: 449 passed, 0 failed, 1 ignored; integration suites passed
- [x] Linux x86_64 JNI release build with glibc 2.17 target
- [x] Interleaved benchmark medians: 18.75% 20.110 -> 11.213 ms (-44.2%); 25% 19.594 -> 12.733 ms (-35.0%); unchanged-density regressions stayed below 3%
## Notes
The benchmark validates the generic x86 crossover decision. AMD Genoa-specific SIMD work is intentionally excluded and requires measurement on the production CPU family.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] perf(ivfpq): speed up transposed PQ8 scans [paimon-vector-index]
Posted by "jerry-024 (via GitHub)" <gi...@apache.org>.
jerry-024 merged PR #76:
URL: https://github.com/apache/paimon-vector-index/pull/76
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] perf(ivfpq): speed up transposed PQ8 scans [paimon-vector-index]
Posted by "shyjsarah (via GitHub)" <gi...@apache.org>.
shyjsarah commented on PR #76:
URL: https://github.com/apache/paimon-vector-index/pull/76#issuecomment-5277494904
+1
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] perf(ivfpq): speed up transposed PQ8 scans [paimon-vector-index]
Posted by "shyjsarah (via GitHub)" <gi...@apache.org>.
shyjsarah commented on code in PR #76:
URL: https://github.com/apache/paimon-vector-index/pull/76#discussion_r3772200784
##########
core/benches/ivfpq_filter_scan_bench.rs:
##########
@@ -0,0 +1,152 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use paimon_vindex_core::distance::MetricType;
+use paimon_vindex_core::io::{write_index, IVFPQIndexReader, PosWriter};
+use paimon_vindex_core::ivfpq::{search_batch_reader_filter, IVFPQIndex, RowIdFilter};
+use rand::rngs::StdRng;
+use rand::seq::SliceRandom;
+use rand::{Rng, SeedableRng};
+use std::hint::black_box;
+use std::io::Cursor;
+use std::time::{Duration, Instant};
+
+const D: usize = 768;
+const M: usize = 96;
+const NLIST: usize = 128;
+const NPROBE: usize = 64;
+const NQ: usize = 64;
+const K: usize = 3;
+const ROWS_PER_LIST: usize = 6_800;
+const WARMUPS: usize = 1;
+const ROUNDS: usize = 3;
+
+struct DensityFilter<'a> {
+ row_ranks: &'a [usize],
+ max_rank: usize,
+}
+
+impl RowIdFilter for DensityFilter<'_> {
+ fn contains(&self, id: i64) -> bool {
+ self.row_ranks
+ .get(id as usize)
+ .is_some_and(|&rank| rank < self.max_rank)
+ }
+}
+
+fn randomized_row_ranks() -> Vec<usize> {
+ let mut rng = StdRng::seed_from_u64(43);
+ let mut row_ranks = vec![0; NLIST * ROWS_PER_LIST];
+ let mut row_order = (0..ROWS_PER_LIST).collect::<Vec<_>>();
+ for list_id in 0..NLIST {
+ row_order.shuffle(&mut rng);
+ let base = list_id * ROWS_PER_LIST;
+ for (rank, &row) in row_order.iter().enumerate() {
+ row_ranks[base + row] = rank;
+ }
+ }
+ row_ranks
+}
+
+fn search(
+ reader: &mut IVFPQIndexReader<Cursor<Vec<u8>>>,
+ queries: &[f32],
+ filter: &DensityFilter,
+) -> Duration {
+ let started = Instant::now();
+ let result = search_batch_reader_filter(reader, queries, NQ, K, NPROBE, Some(filter)).unwrap();
+ let elapsed = started.elapsed();
+ black_box(result);
+ elapsed
+}
+
+fn median(samples: &mut [Duration]) -> Duration {
+ samples.sort_unstable();
+ samples[samples.len() / 2]
+}
+
+fn main() {
+ assert_eq!((NQ, NPROBE), (64, 64), "benchmark production query shape");
+ assert!(
+ std::env::var_os("PAIMON_VINDEX_LOG_IVFPQ_TIMING").is_none(),
Review Comment:
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?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@paimon.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org