.NET 4 Scripting Runtime and IL2CPP performance issue

Using RVO Simulator with threads causes major performance loss. Using these settings:

Scripting Runtime Version: .NET 4
Scripting Backend: IL2CPP
API Compatibility: .NET 2

If I switch the RVO simulator to not use threads then performance actually improves but is still poor.

Using same project but with Scripting Runtime Version set to .Net 3.5, performance is excellent. I did comment on a bug with random crashes and also a fix for that.

The above images show this bug in action.

My game has 5-10 rvo agents tops. Turning off the threading with .net 4 on ios removed the performance issue.

As you can see I was seeing spikes of 20+ms from RVO simulator.

Hi

Thanks.
I have been able to replicate this issue (though not as extreme as in your screenshots). I’ll try to see if I can find the cause of it.

I have updated to latest A* Project and problem persists. Similar to what another user reported, I am getting 40ms on RVOSimulator.Update() and it is pretty consistent. Extreme drop in framerate. I do not have any agents enabled at all. Simply enabling the RVO Simulator script in my scene will cause this. No problems if I build to IL2CPP .Net 3.5 / Mono2.

Hoping there is a fix for this. Thanks.

Hi

After having debugged this, it seems that the culprit is that cross-thread signaling with that configuration is ridiculously slow. Just getting a signal to a thread and back takes around 10 milliseconds. I’m not sure why it is so much worse with this configuration compared to when using .net 3.5 or when using mono2.

However I’ve found that using ManualResetEventSlim instead of ManualResetEvent for synchronization will lead to much better performance. With those changes I can simulate 5000 agents at 100-200 fps (when using a simulation fps of 40 and double buffering), without double buffering it goes down to around 30-60.

Try to replace your RVOCoreSimulator.cs script with this: https://pastebin.com/j4eqtwzE and see if that helps. Let me know how it goes.

I have tested this and looks good. Performance now seems same or very close. Thank you.