Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  OBI Performance degradation over time
#3
(09-01-2024, 10:28 AM)josemendez Wrote: Hi Michael,

What you describe is just how fixed time stepping works in games, nothing odd about it.

Fixed timestepping is a way of updating physics using fixed time intervals. Since games update at a variable frequency (sometimes more FPS, sometimes less), a way of making sure physics stay consistent is by accumulating the amount of time taken by each frame and then calling physics -FixedUpdate(), in Unity's case- as many times as needed to keep up with rendering.

So let's say we are updating physics at 50 hz (one update every 0.02 seconds), and 0.05 seconds have passed since the last frame. We have to update physics 0.05/0.02 = 2 times this frame. There's 0.01 seconds remaining that we will accumulate, so no more physics steps until there's at least 0.02 seconds worth of time accumulated.

Problem is, what happens when a single frame takes a lot of time to process - for whatever reason?. In these cases, a lot of time will be accumulated leading to a lot of physics updates necessary. Updating physics a lot of times is slow though, so this causes the next frame to also take a lot of time, leading to even more physics updates, which in turn make things even slower and leads to even more physics updates, etc. This is a downwards performance spiral situation, generally known as death spiraling, which is what you're experiencing. Once the spiral is in motion, it can be very hard to get the game out of it and the only solution is often to significantly reduce workload for a few frames giving the engine time to recover.

Ideally, your game should have enough performance headroom and run smoothly enough that processing a frame never takes enough time to trigger the spiral. While this isn't easy as it may mean optimizing everything across the board, a simple solution to alleviate this situation is to reduce Unity's "max allowed timestep" setting, which will tell Unity to stop updating physics if a frame takes too much time to process. If this is your first time hitting a timestepping related issue, I'd suggest reading about it online. There's hundreds of very good resources of this topic, some focusing on Unity in particular - since this is common to all game engines, not just Unity or Obi. See:

https://gamedevbeginner.com/how-to-use-f...-in-unity/
http://blog.lidia-martinez.com/fixedupda...step-unity
https://forum.unity.com/threads/what-is-...ep.330116/
https://gafferongames.com/post/fix_your_timestep/

kind regards,

Thanks josemndez. 

That is useful information. But there is something you had not addressed:  the massive effect that destroying the OBI Solvr and Actor is having on performance, the next time I load the scene, leading me to think I should not be destroying the solver, perhaps it is persisting in memory, even after the scene is reloaded. Is that the case? 

Regards,

Michael.
Reply


Messages In This Thread
RE: OBI Performance degradation over time - by michendo - 10-01-2024, 09:45 AM