[Jobs,PhysX] Spike and CPU usage

Hello,

I’m experiencing 2 problems on Unity 2018.1b2 with Jobs and Physx.

-PhysX create many spikes and lags. The scene contains only one FPSController :

I think it’s related to my second problem using Unity.Jobs.

        public struct ParrallelGenerateJob : Unity.Jobs.IJobParallelFor
        {
          
            public void Execute(int ChunkIndex)
            {
DoStuff(); // <----- This function take 20ms maximum
            }
}
ParrallelGenerateJob Job = new ParrallelGenerateJob();
GenerateHandle = Job.Schedule(1024 1);

Actually, jobs are executed all in row without switching to other jobs, and create freeze and lags on CPU.
Maybe because other unity systems can(t process. Here is the result :

Also, sometimes it happens (on editor) that a job is executed on the main thread, and i have a timeline showing ParrallelGenerateJob 1000ms on “Main Thread”;

Am i using Jobs correctly or it is a bug that everything is executed in one row without zero chance for other jobs to be executed.

If i use only IJobs, this problem do not appear and jobs are correctly dispatched between other unity jobs.

Thanks.

I have also experienced the big spikes for Physx. Only thing in the scene is a character controller though. And my jobs take nowhere near that long.

1 Like

I reported this issue a while ago as:
(Case 983582) 2018.1: Physics.Processing performance issues

Unity QA was able to reproduce, here is their reply:

For whatever reason, the issue does not seem to exist in the public issue tracker yet.

1 Like

That’s a bug. Will hopefully be fixed soon, together with the missing 2018.1 (Beta) category…

As for the physics bug: it’s on the radar, but will probably not be addressed until February. I’ll reply with the issuetracker link as soon as I get wind of it.

3 Likes