alexklibisz / elastiknn

Elasticsearch plugin for nearest neighbor search. Store vectors and run similarity search using exact and approximate algorithms.
https://alexklibisz.github.io/elastiknn
Apache License 2.0
368 stars 48 forks source link

Remove unnecessary check in critical path of MatchHashesAndScoreQuery #607

Closed alexklibisz closed 9 months ago

alexklibisz commented 9 months ago

Related Issue

611

Changes

Removing an unnecessary counter check from the critical path of MatchHashesAndScoreQuery. The check originated in https://github.com/alexklibisz/elastiknn/pull/170, at which point it was actually useful. Then #231 removed the original reason/necessity for this check, but it was kept around for some reason.

The check is checking whether the number of hits is less than the number of possible hits going to return true in almost all cases. The only way it returns false is if we match/hit every document in the segment. If that happens, the LSH model parameters are almost certainly suboptimal.

Though this was in the critical path, the benchmark results are almost identical, so it's more of a simplification than a perf improvement:

image

Testing and Validation

Standard CI and benchmarks