potentialpaper

KNN Implementation Details Can Dramatically Change Performance: An Example from Cover Trees

Amol Khanna, Edward Raff

NeurIPS 2026

Edit this page

Or clone it with git

The page gets its repository with its first edit, so start in the web editor.

Or let your agent set it up

It checks and sets up everything: signing in, git, the clone, credentials and an SSH key.

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 kk, and can have up to 111×111\times 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 [1.1,2.0][1.1, 2.0] 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 paper
How does this paper connect to your work? Write how you built on it, compared with it or reproduced it, or add a summary, a critique or errata.
Or make it interactive:
Start writing

add · history

No versions are recorded yet: its preprint, the venues it went to and what they decided, the camera-ready. Missing a version?

We don't know of a submission of this paper to a venue with open reviews. Missing a submission?

Loading the discussion…