com.unity.netcode.gameobjects icon indicating copy to clipboard operation
com.unity.netcode.gameobjects copied to clipboard

perf: Improved performance for large number of NetworkObjects

Open starchitectus opened this issue 3 years ago • 3 comments

Presently every NetworkObject is checked for each client every tick to see if it has dirty NetworkVariables that require syncing. This causes poor performance with large numbers of NetworkObjects as they all are checked multiple times per frame regardless of whether or not they have changed.

This PR changes the behaviour of NetworkVariables such that they register themselves with the NetworkManager for updating when they are marked dirty so there are no redundant checks.

starchitectus avatar May 09 '22 22:05 starchitectus

CLA assistant check
All committers have signed the CLA.

unity-cla-assistant avatar May 09 '22 22:05 unity-cla-assistant

In com.unity.netcode.gameobjects/Runtime/Core/NetworkBehaviourUpdater.cs there is a tiny local variable name inconsistency:

foreach (var dirtyObj in m_DirtyNetworkObjects) vs foreach (var sobj in m_DirtyNetworkObjects) (old local variable name)

PyrateAkananto avatar May 18 '22 08:05 PyrateAkananto

even though this sounds and looks like a bold change, it actually makes quite a lot of sense to me. perhaps, we might consider this as an optimization task/goal some time @Unity-Technologies/multiplayer-sdk

0xFA11 avatar May 24 '22 23:05 0xFA11

Nice PR! Trying to have it work with our test setup required a bit of tweaks.

I've opened: https://github.com/Unity-Technologies/com.unity.netcode.gameobjects/pull/2116 which integrates this plus other changes so that it doesn't break our tests.

OK if I close this and we migrate the discussion over there?

jeffreyrainy avatar Aug 12 '22 19:08 jeffreyrainy

Nice PR! Trying to have it work with our test setup required a bit of tweaks.

I've opened: #2116 which integrates this plus other changes so that it doesn't break our tests.

OK if I close this and we migrate the discussion over there?

Thanks Jeff! Great to see this gaining traction. Ok to close this one.

starchitectus avatar Aug 13 '22 02:08 starchitectus