Search Unity

Question Havok very slow?

Discussion in 'Physics for ECS' started by Pabi, Apr 25, 2023.

  1. Pabi

    Pabi

    Joined:
    Feb 13, 2016
    Posts:
    48
    I am currently developing a tech demo and have been utilizing Havok since the start of the project, almost to the point of taking it for granted.

    Recently, I reached a stage where I needed to dynamically add the velocity and mass component of certain entities to create physics. However, this change resulted in a significant performance drop. I add it to something between 500 to 5k entities.

    Initially, I suspected an error on my part and attempted to identify the issue. Surprisingly, when I switched from Havok to Unity Physics, the performance issue was a lot better!

    Is there a known issue with Havok at the moment? I am up-to-date with the latest DOTS package. Any insights or suggestions would be greatly appreciated.
     
  2. TriceHelix

    TriceHelix

    Joined:
    Mar 6, 2019
    Posts:
    34
    The only thing I can think of (without knowing what you're trying to accomplish specifically) is that you may be creating some sort of sync point. Perhaps the order in which certain component's values are accessed and the physics Systems' dependencies differ between Havok and Unity's default implementation. That would mean a call to something like SystemAPI.Query (which synchronously completes all write operations to the components you're trying to access) could have more overhead and slow everything down significantly, especially if the system calling this function is ordered after the physics systems, since they would schedule these operations asynchronously in the form of jobs but then those jobs have to be completed immediately after, mostly on the main thread.
    Again, total speculation on my end though. The best bet without any feedback from the Unity Devs would be to look at the profiler and see if any physics related jobs are being run right before your operations, and then compare that to how things execute when you don't modify or read from any components. (Maybe also try placing your System in a different System Group?)
     
  3. Pabi

    Pabi

    Joined:
    Feb 13, 2016
    Posts:
    48
    Thank for the help. I disable all job when there is a PhysicsVelocity on the entities, so it can't be a job (or I think).

    Switching to normal physics is like 10x faster. I have no idea yet why. I'll continue my investigation... I was hoping for something obvious like "oh yeah, there is a bug in the latest version of havok, we are going to patch soon".