Skip to content

Deprecate stats and number of calls tracking in KDTree/BallTree (or see if there's a way to speed-up, if useful) #34232

Closed

Description

@itamarst

Describe the workflow you want to enable

#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

  1. vijesh-cloud commented on Jun 10, 2026

    @vijesh-cloud
  2. removed
    Needs Triage
    on Jun 18, 2026
  3. ogrisel commented on Jun 18, 2026

    @ogrisel
    Member

    I agree with your assessment. We can always re-add such profiling code if needed in PRs trying to optimize this code further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions