Open jtibshirani opened 2 years ago
Pinging @elastic/es-search (Team:Search)
Pinging @elastic/es-distributed (Team:Distributed)
ANN must check several HNSW graphs as it searches one segment after another
why is that we can not search multiple hnsw graph in parallel an then merge the result ?
@AkisAya nothing in Elasticsearch currently searches segments in parallel. Any change there needs to be considered carefully as resource contention is a real concern. We would prefer when concurrency support is added, we add it for everything (all queries, all aggregations).
Julie mentions this as an option in the issue description.
Also, in benchmarking, there is not a huge difference in search speed for KNN over multiple segments vs just a single one, as long as the segments are not tiny.
The concurrency bits are now addressed: segments can now be searched in parallel. Enabled in Elasticsearch 8.11 for knn (which runs in the dfs phase) and Elasticsearch 8.12 for the query phase.
Pinging @elastic/es-search-relevance (Team:Search Relevance)
To support ANN search, Elasticsearch indexes the vector values of each segment as an HNSW graph. Usually an index has multiple segments, which means ANN must check several HNSW graphs as it searches one segment after another. With fewer segments, the ANN search is more efficient, since we check a smaller number of graphs. Another way to describe it: searching an HNSW graph is sub-linear in the number of vectors, so it's better to search larger graphs vs. several smaller ones.
It's certainly possible to force merge the index to one segment, but force merge can take substantial time and has some downsides (explained here).
This meta issue explores ideas to improve performance that don't require force merge. These are early ideas and may change.
IndexMemoryController
to no longer flush all pending segments when hitting theindices.memory.index_buffer_size
threshold, and instead only flush the largest pending segment (#34553)index.translog.flush_threshold_size
(512MB by default). Are there ways to avoid bumping up against this limit?index.merge.policy.segments_per_tier
to encourage the merge policy to merge segments more aggressively.index.merge.policy.max_merged_segment
to not stop merging segments at 5GB.index.merge.policy.floor_segment
to further bias the merge policy against small segments.num_candidates
from each segment?