Search Unity

Resolved Physics scheduling bug? Massive drop in performance setting PhysicMass

Discussion in 'Physics for ECS' started by thelebaron, Aug 16, 2022.

  1. thelebaron

    thelebaron

    Joined:
    Jun 2, 2013
    Posts:
    855
    Resolved - didnt realize I had an extra PhysicsStep. Maybe this should error out unless I'm missing the need for multiple of these

    Getting a huge drop in performance when setting the mass for rigidbody ragdolls. Above profiler is prior to ragdolling(kinematic) and below after(non kinematic). Note that this profiler picture is from about 14 constrained body pairs(/joints). Its an extremely low amount of physics entities in the scene at the time of the performance drop.

    A very simplified rundown of what happens is:
    When health is zero, a character entity sets all of it's rigidbody entities to a non kinematic PhysicsMass. When that happens, drop in performance.

    The ParallelCreateContactsJob appears to be the culprit, its a minuscule amount prior to the "switch" and then appears to go into some sort of single threaded stall.
    This happens with both havok and unity physics.
    Also note that if all the ragdoll physics entities(colliders+joints) are destroyed, this stall will continue to occur with the below profiler for a good 10-20 seconds, before it finally settles down.

    Now I have a prior project commit a day ago where this all works without any hitches/slowdowns and obviously somewhere along the way I added something that causes this, but the code introduced does not touch any physics or FixedStepSimulationGroup whatsoever. My only conclusion at this point is there's some sort of scheduling error?

    Unity_7obtjmVrsj.png
     
    Last edited: Aug 16, 2022