KNN Implementation Details Can Dramatically Change Performance: An Example from Cover Trees
Amol Khanna, Edward Raff
NeurIPS 2026
Abstract. Nearest neighbor search algorithms are widely used and have a long history, but we find that key implementation details are seldom reviewed in articles about them. These details can materially impact performance, and thus change the conclusions one makes about a given algorithm's superiority. In this article, we highlight these impacts by reviewing the cover tree as an example, producing RustKNN, a unified Rust implementation of four variants of the cover tree. Our analysis reveals: (1) the optimal query strategy depends critically on , and can have up to factor impact on runtime; (2) the cover tree base parameter, set to 2 in theory and 1.3 in practice, tends to have an optimal value in which can be 20% faster than other settings for a given dataset; (3) micro-optimizations (early-exit distance, packing, triangle pre-filters) compose with early-exit distance being very powerful in high dimensions; and (4) all-nearest-neighbor and held-out benchmarks yield different implementation rankings. We release the implementation with reproducible benchmark infrastructure.
Are you an author? Claim this paper to see who's reading it, with views and other statistics, and to write about it here.
Claim this paperadd · history
Loading the discussion…