Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parallelizing knn and inrange searches #131

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SebastianAment
Copy link

Overview

This PR uses the @threads macro to parallelize inrange and knn searches over independent datapoints.

Benchmarks

Setup

using NearestNeighbors
using BenchmarkTools

d, n = 100, 10_000;
X = randn(d, n);
T = BallTree(X);

On Master

@btime knn(T, X, 3);
  6.150 s (20008 allocations: 9.31 MiB)
@btime inrange(T, X, 5);
  6.271 s (20005 allocations: 9.08 MiB)

With this PR

@btime knn(T, X, 3);
  766.583 ms (20090 allocations: 9.32 MiB)
@btime inrange(T, X, 5);
  797.295 ms (20087 allocations: 9.09 MiB)

This is a factor of 8 improvement, on a 2021 MacBookPro with an M1 Pro and 16 threads.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant