Skip to content

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