Optimize prefix sum computation in Lucene99HnswVectorsReader; fixes #15024#15027
Optimize prefix sum computation in Lucene99HnswVectorsReader; fixes #15024#15027yossev wants to merge 2 commits intoapache:mainfrom
Conversation
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.
|
This PR does not have an entry in lucene/CHANGES.txt. Consider adding one. If the PR doesn't need a changelog entry, then add the skip-changelog label to it and you will stop receiving this reminder on future updates to the PR. |
|
Thank you, this looks good. If you have cycles to run benchmarks, this would be appreciated, you can check out this: https://github.com/mikemccand/luceneutil/blob/main/README.md#running-the-knn-benchmark. |
Thank you, Glad it looks good. Also, I’ll take a look at the benchmark tool you linked and try to run some comparisons if time allows. Appreciate the reference! |
|
The only missing thing is an entry in lucene/CHANGES.txt but we can deal with it later. |
|
Perfect. |
|
@yossev FYI you'll need to resolve conflicts since another change touched the same lines of code. I'm curious if you had any success with benchmarking? |
Thanks for the heads-up! I noticed that the recent changes in Regarding benchmarking ,I’ll run it after the conflicts are resolved so results reflect the latest code. |
I was just giving credit to #14979 to the optimization i made in this case, not saying it changed anything. |
…prefix sum computation with GroupVIntUtil
|
This PR does not have an entry in lucene/CHANGES.txt. Consider adding one. If the PR doesn't need a changelog entry, then add the skip-changelog label to it and you will stop receiving this reminder on future updates to the PR. |
|
@yossev see the output of the build failure, the build is unhappy with formatting, you need to run |
|
This PR has not had activity in the past 2 weeks, labeling it as stale. If the PR is waiting for review, notify the dev@lucene.apache.org list. Thank you for your contribution! |
|
This PR has not had activity in the past 2 weeks, labeling it as stale. If the PR is waiting for review, notify the dev@lucene.apache.org list. Thank you for your contribution! |
|
I would be happy to merge and backport this once merge conflicts and formatting is tidied @yossev |
|
This PR has not had activity in the past 2 weeks, labeling it as stale. If the PR is waiting for review, notify the dev@lucene.apache.org list. Thank you for your contribution! |
|
Hello @yossev friendly ping :). Once conflicts & formatting are fixed, I can merge and backport. We should also have a CHANGES entry under optimizations for 10.4.0 |
|
This PR has not had activity in the past 2 weeks, labeling it as stale. If the PR is waiting for review, notify the dev@lucene.apache.org list. Thank you for your contribution! |
|
This PR has not had activity in the past 2 weeks, labeling it as stale. If the PR is waiting for review, notify the dev@lucene.apache.org list. Thank you for your contribution! |
Replaced the two-step prefix sum loop in
Lucene99HnswVectorsReaderwith a single-loop variant that avoids redundant memory access and improves performance.Previous approach:
New approach:
This change follows the suggestion from issue #14979 and has the same functional behavior with slightly better efficiency.