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

Performance: optimize MatchHashesAndScoreQuery for case where a hash occurs once (96% recall at 190 qps) #612

Closed alexklibisz closed 9 months ago

alexklibisz commented 9 months ago

Related Issue

611

Changes

There is one LSH model (PermutationLsh) which can emit the same hash multiple times. Because of this, MatchHashesAndScoreQuery has to account for the fact that the same hash can occur multiple times. Through some trial and error, I figured out that this actually has a measurable impact on performance.

So this PR adds an optimized case to MatchHashesAndScoreQuery for hashes that occur once.

This gets the 96% recall up to 190 qps, only 10 qps away from the goal of #611.

image

(One of the benchmarks was as high as 195 qps, but I decided to advertise the lower value)

Testing and Validation

Standard CI and benchmarking