You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Deprecate stats and number of calls tracking in KDTree/BallTree (or see if there's a way to speed-up, if useful) #34232
#34187 sped up multi-threaded operations by using a thread-local, but slowed down single-threaded operations.
This suggests the amount of new work involved is meaningful, and slowing down multi-threaded operations as well. It was still worth it (the CPU time was counterbalanced by removing lots of time spent doing cross-CPU-core memory locking), but still suggests a bunch of computational work is involved that would be nice to speed up.
Describe your proposed solution
It's not clear if anyone actually uses these stats (BallTree.get_tree_stats(), BallTree.get_n_calls()), so deprecating it seems like one option; they can then be deleted wholesale when the time comes.
Another option is seeing if there's some way to make it faster, e.g. maybe there's a loop that predicatably increments a counter by 1 n times and could be replaced with incrementing by n just once. If there is, may well be worth doing immediately whether or not deprecation happens.
Describe alternatives you've considered, if relevant
No response
Additional context
Main question I have to maintainers here is if deprecation is possible.
When I get to this I will inspect code to see if there is a potential for speedup right now; there might not be, with deprecation the only option.
Activity
vijesh-cloud commentedon Jun 10, 2026
ogrisel commentedon Jun 18, 2026
I agree with your assessment. We can always re-add such profiling code if needed in PRs trying to optimize this code further.