-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimize binary search call #13595
base: main
Are you sure you want to change the base?
Optimize binary search call #13595
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch! Do we have suitable benchmarks to measure this (ideally a combination of lexical + vector search)?
This makes sense to me. Maybe we should go one step further and perform an exponential search instead, e.g. by reusing |
The |
I think exponential search will only outperform binary search in this case if we expect the next target to be relatively close to the "min" we're constantly "pushing up" (thanks to your change). Is that the case? (Specifically, I think the math works out that exponential search is only better if the target is in the next |
If |
Ah yeah, OK thanks @jpountz. Makes sense. |
@jpountz I was reading |
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! |
@jpountz I have changed the code to exponential search, and move the functionality to ArrayUtil. We still need two different method for |
Description
I think
advance
is usually not called in backward, so we can run the binary search from the current position +1 instead of 0. Also cap the fromIndex to scoreDocs.length to avoid overflow.From the Javadoc of
advance