Skip to content

Optimize prefix sum computation in Lucene99HnswVectorsReader#1

Merged
yossev merged 1 commit intomainfrom
Optimize-prefix-sum-computation-in-Lucene99HnswVectorsReader
Aug 1, 2025
Merged

Optimize prefix sum computation in Lucene99HnswVectorsReader#1
yossev merged 1 commit intomainfrom
Optimize-prefix-sum-computation-in-Lucene99HnswVectorsReader

Conversation

@yossev
Copy link
Copy Markdown
Owner

@yossev yossev commented Aug 1, 2025

Replaced the two-step prefix sum loop in Lucene99HnswVectorsReader with a single-loop variant that avoids redundant memory access and improves performance.

Fixes: apache#15024

Previous approach:

  • Read first value separately.
  • Then used previous buffer element + readVInt().

New approach:

  • Accumulates sum in a single pass and assigns directly.

This change follows the suggestion from issue apache#14979 and has the same functional behavior with slightly better efficiency.

Replaced the two-step prefix sum loop in `Lucene99HnswVectorsReader` with a single-loop variant that avoids redundant memory access and improves performance.

Previous approach:
- Read first value separately.
- Then used previous buffer element + readVInt().

New approach:
- Accumulates sum in a single pass and assigns directly.

This change follows the suggestion from issue apache#14979 and has the same functional behavior with slightly better efficiency.
@yossev yossev merged commit a49d72a into main Aug 1, 2025
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.

Improve prefix sum in Lucene99HnswVectorsReader

1 participant