Skip to content

perf: ANN optimizations - SwissHashSet, AVX2 distance, insert_fast - #1252

Merged
Deyu Kong (cave-g-f) merged 1 commit into
jegao/LabelHotFixfrom
deyu/agentic2
Jul 13, 2026
Merged

Deyu Kong (cave-g-f) merged 1 commit into
jegao/LabelHotFixfrom
deyu/agentic2

Conversation

@cave-g-f

Copy link
Copy Markdown

Port hot-path optimizations from parent repo PR 6610806 (commit 844664001):

  • swiss_hash_set.h: New SSE2/SIMD-optimized Swiss table hash set for uint32_t keys with O(occupied_slots) clear and ~87.5% load factor. Replaces tsl::robin_set for inserted_into_pool_rs.
  • neighbor.h: Add NeighborMinHeap::insert_fast() with AVX2-accelerated linear scan over a contiguous float distance array (_dist_arr) for faster insertion-point finding.
  • index.cpp: Refactor iterate_to_fixed_point() to interleave prefetch, distance computation, and immediate insert; remove separate dist_scratch allocation; mark nodes visited and process neighbors under the same shared lock (eliminates redundant lock/unlock).
  • pq_l2_distance.cpp: AVX2 inner loop for chunk-wise PQ centroid distance computation (8-wide _mm256_fmadd_ps).
  • scratch.h/.cpp: Switch _inserted_into_pool_rs type to SwissHashSet and skip clear() on empty containers.
  • Does this PR have a descriptive title that could go in our release notes?
  • Does this PR add any new dependencies?
  • Does this PR modify any existing APIs?
  • Is the change to the API backwards compatible?
  • Should this result in any changes to our documentation, either updating existing docs or adding new ones?

Reference Issues/PRs

What does this implement/fix? Briefly explain your changes.

Any other comments?

Comment thread include/neighbor.h
Comment thread src/pq_l2_distance.cpp
}

template <typename data_t>
void PQL2Distance<data_t>::prepopulate_chunkwise_distances(const float *query_vec, float *dist_vec)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this function isn't called in current scenarios, the change should not take effect

Port hot-path optimizations from parent repo PR 6610806 (commit 844664001):

- swiss_hash_set.h: New SSE2/SIMD-optimized Swiss table hash set for
  uint32_t keys with O(occupied_slots) clear and ~87.5% load factor.
  Replaces tsl::robin_set for inserted_into_pool_rs.
- neighbor.h: Add NeighborMinHeap::insert_fast() with AVX2-accelerated
  linear scan over a contiguous float distance array (_dist_arr) for
  faster insertion-point finding.
- index.cpp: Refactor iterate_to_fixed_point() to interleave prefetch,
  distance computation, and immediate insert; remove separate
  dist_scratch allocation; mark nodes visited and process neighbors
  under the same shared lock (eliminates redundant lock/unlock).
- pq_l2_distance.cpp: AVX2 inner loop for chunk-wise PQ centroid
  distance computation (8-wide _mm256_fmadd_ps).
- scratch.h/.cpp: Switch _inserted_into_pool_rs type to SwissHashSet
  and skip clear() on empty containers.
@cave-g-f
Deyu Kong (cave-g-f) merged commit d759aed into jegao/LabelHotFix Jul 13, 2026
3 of 39 checks passed
@cave-g-f
Deyu Kong (cave-g-f) deleted the deyu/agentic2 branch July 13, 2026 09:53
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.

2 participants