Sudden performance drop adding more soft bodies

User avatar
dphil
Posts: 237
Joined: Tue Jun 29, 2010 10:27 pm

Sudden performance drop adding more soft bodies

Post by dphil »

I have recently implemented soft body dynamics, and it seems to work fine. However, in testing performance, I successively add soft bodies to see how much the simulation can handle. With the particular mesh I am using, I can add roughly 22 and it stays at a solid 30 fps. Adding a couple more puts it somewhere between 26 and 30. But then consistently around the 26th or 27th soft body added to the simulation, it suddenly drops to a consistent 15 fps, at which it stays even when adding more soft bodies after that (up to a point, of course). I would normally expect a linear (or, perhaps, exponential) decay in performance. So it would seem there is some artificial limit in the processing...some data structure becoming full, etc. Any ideas?

Note: I thought I remembered reading a thread about this problem (either with soft or rigid bodies) a while ago, but could not find it.
User avatar
dphil
Posts: 237
Joined: Tue Jun 29, 2010 10:27 pm

Re: Sudden performance drop adding more soft bodies

Post by dphil »

Still rather curious about this. I always hit some seemingly artificial cap after about 25-35 soft bodies added to the simulation (even if not colliding with each other), where my framerate suddenly cuts in half when a single additional soft body is added. I'd like to know what could be causing this sudden drop and if there is a better way around it.

Note: I'm not doing anything special on my end with the soft bodies such as storing them in them peculiar way which could cause such behaviour. I treat them like any other objects in my simulation, such as rigid bodies, which I can add by the hundreds without such sudden performance drops (instead, it declines gradually as one would expect).
mi076
Posts: 144
Joined: Fri Aug 01, 2008 6:36 am
Location: Bonn, Germany

Re: Sudden performance drop adding more soft bodies

Post by mi076 »

vsync?
User avatar
dphil
Posts: 237
Joined: Tue Jun 29, 2010 10:27 pm

Re: Sudden performance drop adding more soft bodies

Post by dphil »

Hm, I'm not familiar with vsync, but I looked into it a bit and I don't believe that's it. I'm on a mac, and disabling "beam sync" (vsync) via Quartz Debug before or during my simulation has no effect. Still get an fps that sits at 30 for (in my case) up to ~35 soft bodies added, then wavers a bit when I add the next 5 or so, sometimes dipping a bit to a steady 25-28 fps, then drops to 15 fps with a single additional soft body, and remains almost perfectly steady around 14-15 fps for the next 40(!) or so soft bodies, at which point it starts decreasing again and then hits another stable point around 10fps, and so on. With more complex soft bodies, I get the same results but with a fewer number added (eg. 15fps with only 25 bodies added, etc).

Does anyone else get (or not get) this behaviour when adding many soft bodies?
User avatar
dphil
Posts: 237
Joined: Tue Jun 29, 2010 10:27 pm

Re: Sudden performance drop adding more soft bodies

Post by dphil »

Ok, after some testing and profiling I *think* I have discovered that this is an issue with my simulation timer. I am going to go ahead with that assumption and consider this not a bullet issue (other than the fact that the heavy soft body computation time is probably what is messing up the timer :) ).