bump the default leafsize from 10 to 25 #198
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Since this package was written CPUs have in general become faster (at a rate faster than memory can be fetched). The choice of a good default leafsize might therefore be worth reevaluating. Remember that with a large leafsize we have to traverse fewer nodes in the tree while we have to explicitly check more points for the distance. As CPUs gets faster compared to memory it is generally expected that
leafsize
can be increased.The checks / benchmarks below are artificial but in lack of real benchmark data it is the best I have.
First, let's look at the number of flops required for a leafsize of 10 vs 25 (here using a BallTree):
So the flops are roughly equal. However, instead of traversing through a bunch of nodes in the
leafsize=10
case we instead just blast through and evaluate points (which if the tree is reordered are all laying next to each other in memory):The memory occupied by a tree with a larger leaf size is also smaller:
Also, let's spot check a benchmark for KDTree:
where the difference is smaller albeit still noticeable.