Skip to content

Commit

Permalink
feat: reduce the rayon block size to make it faster with multithreads (
Browse files Browse the repository at this point in the history
…#14)

Signed-off-by: Keming <[email protected]>
  • Loading branch information
kemingy authored Dec 11, 2024
1 parent 43eff6a commit 84ee909
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/kmeans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const EPS: f32 = 1.0 / 1024.0;
const MIN_POINTS_PER_CENTROID: usize = 39;
const MAX_POINTS_PER_CENTROID: usize = 256;
const LARGE_CLUSTER_THRESHOLD: usize = 1 << 20;
const RAYON_BLOCK_SIZE: usize = 1024 * 32;
const RAYON_BLOCK_SIZE: usize = 64;

/// Assign vectors to centroids.
pub fn assign(vecs: &[f32], centroids: &[f32], dim: usize, distance: Distance, labels: &mut [u32]) {
Expand Down
2 changes: 2 additions & 0 deletions src/rabitq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ pub fn project(vec: &[f32], orthogonal: &MatRef<f32>) -> Col<f32> {
}

// Get the min/max value of the residual of two vectors.
#[inline]
fn min_max_raw(res: &mut [f32], x: &[f32], y: &[f32]) -> (f32, f32) {
let mut min = f32::MAX;
let mut max = f32::MIN;
Expand Down Expand Up @@ -130,6 +131,7 @@ pub fn min_max_residual(res: &mut [f32], x: &[f32], y: &[f32]) -> (f32, f32) {
}

// Quantize the query residual vector.
#[inline]
fn scalar_quantize_raw(
quantized: &mut [u8],
vec: &[f32],
Expand Down

0 comments on commit 84ee909

Please sign in to comment.