-
Notifications
You must be signed in to change notification settings - Fork 836
chore(query): Accelerate vector index quantization score calculation with SIMD #18957
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
🤖 CI Job Analysis
📊 Summary
❌ NO RETRY NEEDEDAll failures appear to be code/test issues requiring manual fixes. 🔍 Job Details
🤖 AboutAutomated analysis using job annotations to distinguish infrastructure issues (auto-retried) from code/test issues (manual fixes needed). |
9dc2366 to
e72e701
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] | ||
| if is_x86_feature_detected!("sse4.1") { | ||
| unsafe { | ||
| let score = match self.metadata.vector_parameters.distance_type { | ||
| DistanceType::Dot | DistanceType::L2 => { | ||
| impl_score_dot_sse(q_ptr, v_ptr, self.metadata.actual_dim as u32) | ||
| } | ||
| DistanceType::L1 => { | ||
| impl_score_l1_sse(q_ptr, v_ptr, self.metadata.actual_dim as u32) | ||
| } | ||
| }; | ||
|
|
||
| return self.metadata.multiplier * score as f32 + query.offset + vector_offset; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid calling SSE routines built with AVX-only target
The SSE fallback is executed whenever is_x86_feature_detected!("sse4.1") is true, but the build script always compiles cpp/sse.c with -march=haswell (see src/query/storages/common/index/build.rs lines 34‑45), which emits AVX/AVX2 instructions. On an x86_64 machine that supports SSE4.1 but not AVX/AVX2, the check below will still enter the SSE branch and execute functions containing AVX instructions, leading to an Illegal instruction crash before the scalar fallback is reached. The SSE branch either needs to be gated on AVX as well or the SSE object must be compiled for a baseline SSE target.
Useful? React with 👍 / 👎.
I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/
Summary
This PR significantly optimizes the vector index quantization score calculation by replacing the standard scalar computation with a SIMD-accelerated implementation. This change leads to substantial reductions in query latencies for vector search operations.
Performance Improvements: Comprehensive benchmark tests have been conducted to validate the impact of this optimization. The results demonstrate significant improvements in query QPS and latencies:
fixes: #[Link the issue here]
Tests
Type of change
This change is