Huge spikes every 1-3 seconds

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:

Entities
    .ForEach((ref PhysicsVelocity velocity, in MoveIntent moveIntent, in MaxSpeed maxSpeed) =>
    {
        velocity.Linear = moveIntent.Direction.xy_() * maxSpeed.Value;
    })
    .ScheduleParallel();

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

Is your jobs debugger enabled? Or the memory leak detection system? Try disabling those 2 when looking at perf. Also burst safety checks…

1 Like

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 :smile:

2 Likes

Open a new Unity and look in the profiler.
Do you have the spikes in an empty scene?