Performance Spikes

I am experiencing bad performance spikes every few seconds of gameplay:


(RichNavMeshAgent is just RichAI with a different name.)

There seem to be a few causes:

  • RichAI’s TraverseFunnel.
  • Seeker.StartPath method eventually calls ThreadControlQueue.Push which apparently calls Monitor.Exit which can take its sweet time, up to 15 milliseconds.
  • Cut Poly can allocate 0.6 MB and took 82.45 milliseconds one time. Another time 188.34 milliseconds. I presume eliminating NavMeshCuts will remedy that, but still worrisome.
  • ReplaceTile also can take a considerable amount of time, such as 42.26 milliseconds for five calls.

I am guessing upgrading to Unity 2020 would help with the cutting? What else would be improved?

What can be done about the Monitor.Exit stemming form Seeker.StartPath calls eating a ton of time? Seeker.StartPath is called all the time in an RTS, so I don’t know how to minimize that.

Any obvious performance pitfalls I could be accidentally causing?

Hi

How large is your map? (in nodes)
Do you have a screenshot of your settings?

Having Monitor.Exit take up any significant time is very odd. That’s just releasing a lock which should be almost instant. If you are using an old version of Unity I’d recommend upgrading to make sure you are using the latest .net runtime.