Netcode for GameObjects performance and allocations

Hi, we’re using nfgo for our new title and during testing we saw it taking up a lot of our frametime.
Deserialization of the networktransform messages is taking up most of the time and also allocating memory.

There is quite a lot of networktransforms moving (~90), but I guess my main questions are what is going on with all these memory allocations here and is this expected performance?

Quest 2, nfgo 1.11.0, unity 2022.3.51

1 Like

I did some deep dives into those NetworkSomething components. Now I‘m staying away from them as much as possible. They‘re convenient but also (naturally) highly inefficient as they are made to be all encompassing they leave plenty of optimization opportunities untapped.

It‘s not that they aren‘t well optimized, I can‘t argue that. But if you have 100 individual NetworkTransform components it‘s obvious these are going to be far less efficient as gathering all the transform values during the network tick, serialize them yourself, ideally use BytePacker, and then you end up with a single stream or byte array to send out. This even gives you the option to Brotli compress the bytes if necessary, or reducing the send rate, etc etc.

Definitely worth the manageable extra effort specifically when you‘re on a platform with limited resources. IMO you can‘t afford the Network* conveniences on a Quest with that many networked objects.

In my 100 units test case, I went from 250 KiB/s (NetworkTransform with all optimizations enabled) down to 50 KiB/s just because of the single loop, single stream optimization. And then 25 KiB/s with compression and other optimizations.

1 Like

I had hoped that it could handle a bit more out of the box.
I did a test comparison with Photon Fusion and Fusion only used 1/3 the cpu time for the same amount of objects with their built-in NetworkTransforms.

But well, custom serialization or networking solution switch it is.
Don’t know why I thought I could use a Unity solution as it is :man_shrugging: