Search Unity

3k havok sphere colliders drop performance after a small tim

Discussion in 'Physics for ECS' started by doompr, Feb 25, 2021.

  1. doompr

    doompr

    Joined:
    Feb 27, 2015
    Posts:
    19
    Hey everyone,

    So i've got a scene with roughly 3000 sphere colliders rolling around.
    It runs at 60fps (vsync) for 10-20 seconds and after that it starts going down & up randomly and ultimately goes down to 3fps. Only for it to bounce back to 60 at some point.

    25-02-2021-20-56-37.jpg

    The same scene can run at a stable 60fps with 5k sphere colliders aswell for some reason, so it's not the amount it feels like.

    Upon profiling it seems that the Havok StepJob takes a very long time, hence it dropping to 3fps. But at some points its just a stable 60fps, can anyone guide me into the direction of why this is so unstable without any obvious reason?

    havokweird.png
     
  2. milos85miki

    milos85miki

    Joined:
    Nov 29, 2019
    Posts:
    197
    FixedRateCatchUpManager is trying to catch up on physics work, as your screenshot shows 4 StepJobs in a row. Looks like physics steps became too expensive for the fixed timestep setting at some point (heavy scene). I'd recommend reading this thread to learn about fixed timestep, identifying the first "heavy" frame and then figuring out what to do (probably reduce number of bodies or increase fixed timestep duration). You can see how we're increasing fixed timestep (reduce physics FPS) in UnityPhysicsSamples\Assets\Demos\2. Setup\2b. Motion Properties\Scripts\MotionSmoothingSetup.cs .
     
    petarmHavok, doompr and steveeHavok like this.
  3. doompr

    doompr

    Joined:
    Feb 27, 2015
    Posts:
    19
    Oh that sounds so logical reading it now, it wasnt clear to me due to the inconsistency of the heavy frames. I now remember Besiege also using a system to slow down the physicsstep when scene's become too heavy, so i'll definitely take that approach. Thanks for the helpful info & links!