Skip to content

Conversation

@b41sh
Copy link
Member

@b41sh b41sh commented Nov 12, 2025

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:

  • QPS: Increased from 84.58 to 86.15 (a ~1.8% improvement).
  • Serial_latency_p99: Reduced from 87.6ms to 45.3ms (a ~48.3% improvement).
  • Serial_latency_p95: Reduced from 78.7ms to 42.9ms (a ~45.5% improvement).

fixes: #[Link the issue here]

Tests

  • Unit Test
  • Logic Test
  • Benchmark Test
  • No Test - Explain why

Type of change

  • Bug Fix (non-breaking change which fixes an issue)
  • New Feature (non-breaking change which adds functionality)
  • Breaking Change (fix or feature that could cause existing functionality not to work as expected)
  • Documentation Update
  • Refactoring
  • Performance Improvement
  • Other (please describe):

This change is Reviewable

@github-actions github-actions bot added the pr-chore this PR only has small changes that no need to record, like coding styles. label Nov 12, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 12, 2025

🤖 CI Job Analysis

Workflow: 19360212629

📊 Summary

  • Total Jobs: 83
  • Failed Jobs: 40
  • Retryable: 0
  • Code Issues: 40

NO RETRY NEEDED

All failures appear to be code/test issues requiring manual fixes.

🔍 Job Details

  • 🚫 linux / sqllogic / ee (parquet): Cancelled by user
  • 🚫 linux / sqllogic / ee (native): Cancelled by user
  • 🚫 linux / sqllogic / cluster (crdb, 2c8g, 2, hybrid): Cancelled by user
  • 🚫 linux / sqllogic / cluster (crdb, 2c8g, 2, http): Cancelled by user
  • 🚫 linux / sqllogic / cluster (tpch, 2c8g, hybrid): Cancelled by user
  • 🚫 linux / sqllogic / cluster (cluster, 2c8g, hybrid): Cancelled by user
  • 🚫 linux / sqllogic / cluster (ydb, 2c8g, hybrid): Cancelled by user
  • 🚫 linux / sqllogic / cluster (tpch, 2c8g, http): Cancelled by user
  • 🚫 linux / sqllogic / cluster (tpcds, 2c8g, http): Cancelled by user
  • 🚫 linux / sqllogic / cluster (tpcds, 2c8g, hybrid): Cancelled by user
  • 🚫 linux / sqllogic / cluster (base, 2c8g, 2, hybrid): Cancelled by user
  • 🚫 linux / sqllogic / standalone (crdb, 2c8g, hybrid): Cancelled by user
  • 🚫 linux / sqllogic / cluster (cluster, 2c8g, http): Cancelled by user
  • 🚫 linux / sqllogic / standalone (base, 2c8g, hybrid): Cancelled by user
  • 🚫 linux / sqllogic / standalone (base, 2c8g, http): Cancelled by user
  • 🚫 linux / sqllogic / standalone (ydb, 2c8g, hybrid): Cancelled by user
  • 🚫 linux / sqllogic / standalone (tpcds, 2c8g, hybrid): Cancelled by user
  • 🚫 linux / sqllogic / standalone (ydb, 2c8g, http): Cancelled by user
  • 🚫 linux / sqllogic / standalone (crdb, 2c8g, http): Cancelled by user
  • 🚫 linux / sqllogic / standalone (tpch, 2c8g, hybrid): Cancelled by user
  • 🚫 linux / sqllogic / standalone (standalone, 2c8g, http): Cancelled by user
  • 🚫 linux / sqllogic / standalone (tpcds, 2c8g, http): Cancelled by user
  • 🚫 linux / sqllogic / stage (s3, hybrid, sub_path, small): Cancelled by user
  • 🚫 linux / sqllogic / stage (fs, hybrid, full_path, large): Cancelled by user
  • 🚫 linux / sqllogic / stage (s3, http, full_path, large): Cancelled by user
  • 🚫 linux / sqllogic / standalone (tpch, 2c8g, http): Cancelled by user
  • 🚫 linux / sqllogic / stage (s3, hybrid, full_path, small): Cancelled by user
  • 🚫 linux / sqllogic / stage (s3, hybrid, full_path, large): Cancelled by user
  • 🚫 linux / sqllogic / stage (s3, hybrid, sub_path, large): Cancelled by user
  • 🚫 linux / sqllogic / stage (fs, hybrid, sub_path, small): Cancelled by user
  • 🚫 linux / sqllogic / stage (fs, http, full_path, small): Cancelled by user
  • 🚫 linux / sqllogic / stage (fs, http, sub_path, small): Cancelled by user
  • 🚫 linux / sqllogic / stage (fs, hybrid, full_path, small): Cancelled by user
  • 🚫 linux / sqllogic / stage (s3, http, sub_path, large): Cancelled by user
  • 🚫 linux / sqllogic / stage (fs, http, sub_path, large): Cancelled by user
  • 🚫 linux / sqllogic / stage (s3, http, sub_path, small): Cancelled by user
  • 🚫 linux / sqllogic / stage (fs, hybrid, sub_path, large): Cancelled by user
  • 🚫 linux / sqllogic / stage (s3, http, full_path, small): Cancelled by user
  • 🚫 linux / sqllogic / stage (fs, http, full_path, large): Cancelled by user
  • 🚫 linux / sqllogic / standalone (standalone, 2c8g, hybrid): Cancelled by user

🤖 About

Automated analysis using job annotations to distinguish infrastructure issues (auto-retried) from code/test issues (manual fixes needed).

@b41sh b41sh force-pushed the chore-hnsw-quantization-simd branch from 9dc2366 to e72e701 Compare November 12, 2025 07:33
@b41sh b41sh marked this pull request as ready for review November 14, 2025 09:27
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a 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".

Comment on lines +183 to +196
#[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;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-chore this PR only has small changes that no need to record, like coding styles.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant