broadphase performance

Hi,

does anybody have numbers/evidence on the performance of the Box2D broadphase in different situations/implementations, and particularly how it scales with the number of bodies (I'd expect a O(n*logn) behaviour)? I read in some forum post that in the ActionScript implementation this seems to be a bottleneck, but other posts suggest that for typical games the broadphase takes only a fraction of total Box2D time. Is this still true for, say, 1000 or 10,000 bodies?

I have an idea (and initial prototype) for a O(n) broadphase (in contrast to the O(n*logn) dynamic tree) that has some nice properties for physics simulations, but I don't want to waste my time implementing it if there's no demand...
If somebody is interested to have this in Box2D I'd be happy to implement it if somebody can help me a bit with the current Box2D broadphase source code.
Assuming the tree is balanced, insertion and deletion is O(log N), just like any other tree. Pair collection is optimized by using enlarged AABBs. So the per-frame cost is O((M + K) * log N), where M is the number of shapes added or removed from the world and K is the number of awake bodies that have moved out of their enlarged AABBs. You can keep M low by staggering insertions and deletions over several frames. In many game scenarios the average per frame cost is lower than O(N).

A big question is the tree balance. The tree is self-balancing but degenerate input patterns can leave the tree unbalanced for many frames. This can be avoided by using a somewhat random insertion order (don't insert big tile grids in sequential order).

Pierre Terdiman (http://www.codercorner.com/blog/) implemented an O(N) broad-phase based on a radix (bucket) sort. It has been shown that dynamic trees are faster on this site: http://bulletphysics.org

Original thread: https://box2d.org/forum/viewtopic.php?t=5926