Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Resolved Huge spikes every 1-3 seconds

Discussion in 'Physics Previews' started by bobbaluba, Jun 8, 2020.

  1. bobbaluba

    bobbaluba

    Joined:
    Feb 27, 2013
    Posts:
    81
    Hi,
    I've got a very simple scene with just a cube moving around, nothing fancy.

    The only thing I do is basic movement for a cube:

    Code (CSharp):
    1. Entities
    2.     .ForEach((ref PhysicsVelocity velocity, in MoveIntent moveIntent, in MaxSpeed maxSpeed) =>
    3.     {
    4.         velocity.Linear = moveIntent.Direction.xy_() * maxSpeed.Value;
    5.     })
    6.     .ScheduleParallel();
    upload_2020-6-8_8-27-10.png

    Most of the time, everything is fine, physics run in 2-3 ms. Occasionally (every 1-3 seconds), however, I will get huge spikes of in either ~100 ms in BuildPhysicsWorld or ~50 ms in StepPhysicsWorld.

    I've got burst enabled and enabled synchronous compilation.

    Am I doing something wrong? Or is this really not at all ready to be used?

    EDIT: I'm using Unity.Physics 0.3.2
     
  2. petarmHavok

    petarmHavok

    Joined:
    Nov 20, 2018
    Posts:
    461
    Is your jobs debugger enabled? Or the memory leak detection system? Try disabling those 2 when looking at perf. Also burst safety checks...
     
    bobbaluba likes this.
  3. bobbaluba

    bobbaluba

    Joined:
    Feb 27, 2013
    Posts:
    81
    Hey, thanks for the suggestion! I tried disabling the jobs debugger, and the issue was gone. Then I enabled it again, and I still had no problems... Maybe all it really needed was a Unity restart :S

    In any case, running with 20k rigidbodies now without any issues, physics still at ~3 ms :D
     
  4. AlanMattano

    AlanMattano

    Joined:
    Aug 22, 2013
    Posts:
    1,501
    Open a new Unity and look in the profiler.
    Do you have the spikes in an empty scene?