Skip to content

Optimisation for large scale NBLAST #20

Description

@jefferis

Hi @clbarnes,
@schlegelp and @NikDrummond reminded me about this effort today. This is not really an issue, but I figure the discussion may as well live with the repo. I was curious about where you had got with optimisation and whether your progress is likely to be of interest for us.

The main use case that causes us trouble at the moment is when we are dealing with N>10K neurons with median 500 nodes each in "dotprops" format. My analysis in this case is that with the number of comparisons being N^2 that the costs of the preprocessing steps (making the dotprops objects etc which are ~ N) are largely irrelevant (and can often be cached).

Therefore the areas for optimisation should be the actual comparison step. The R implementation typically spends 75+% of it's time inside the nabor::knn function. This wraps an efficient C++ nearest neighbour library. There are a few possible ways that things could be improved

  1. kd trees are rebuilt for each comparison. this sounds wasteful but in my experience the query time is greater than the build time (typical splits are 1/3 build 2/3 query for the number of nodes we use), so although there is some room for improvement here, it's not huge. The downside is that keeping the kd trees in memory does have a space penalty that becomes significant when dealing with a lot of neurons.

A really efficient implementation could potentially achieve ~ 2x speedup if the build could be made one time only (1/3 of 75% =25% total) and the fat associated with the calling R code be removed (25% of total). There could be an additional speed gain if the points could be converted to 32 bit or even 16 bit ints.

  1. the potential large gain would be if we could spatially index both the query and target points and use that to speed up the all by all point query problem. Some time back, I experimented a bit with postgresql and an R* library (I forget which now) and the results were not encouraging, but these were really focussed on indexing all points in the dataset simultaneously, whereas we need to handle group membership i.e. each neuron. Furthermore I did not figure out how to exploit the situation of having indices for both query and target neurons. I am curious if you have managed this. I looked into the literature a while back, but it was actually quite thin and I couldn't really find implementations.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions