Search Unity

UnityPhysics: StepPhysicsWorld taking suspicious amount of time when "multithreaded" is on

Discussion in 'Physics for ECS' started by PhilSA, Feb 7, 2021.

  1. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    I have a nearly empty scene: 2 static box colliders, and one kinematic capsule

    When I have "UnityPhysics" and "multithreaded" on in the PhysicsStep component, the profiler tells me StepPhysicsWorld takes over 2ms. When "multithreaded" is off, StepPhysicsWorld takes about 0.1ms.

    It seems that problem isn't present with Havok (when multithreaded, StepPhysicsWorld just takes 0.1ms with Havok), and I also don't think the problem was there in UnityPhysics 0.4. Unsure about whether it was there or not in 0.5

    Has anyone else seen similar results?
     
    Last edited: Feb 8, 2021
  2. milos85miki

    milos85miki

    Joined:
    Nov 29, 2019
    Posts:
    197
    Hi @PhilSA , just to confirm - did you test on the same scene without changing anything but simulation type and multithreaded check box? Use Job Threads is ON and Jobs debugger is OFF?

    I'm seeing the diff with UnityPhysics as well, but it's way less drastic: usually 0.15 vs 0.6, highest 0.2 vs 0.8 ms. I tried the hello world and large mesh scenes from the samples, timings of StepPhysicsWorld are very similar (it just schedules jobs). Not surprised by the fact there is some diff, because it costs more to schedule jobs on all worker threads, but 2 ms really sounds too big and should not happen.

    Edit: I managed to repro with Jobs Debugger ON, so please check with it being OFF.
     
    Last edited: Feb 8, 2021
  3. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    ah, yes, it was because of the Jobs Debugger. False alarm!