Rep with notify - costly?

Hi,

rep with notify seem to work similar to bind delegates in some way. Since I saw some video from epic where they told that bind delegates are relatively expensive I wonder if the same does apply to rep with notify. Are they just as expensive or cheaper? Would it be problematic to have several hundred or even thousands of rep notifys active?

bump :wink: I would like to know too !

#Efficient Network Replication

Yes, having thousands of rep notify vars could become prohibitively expensive in perhaps an unexpected way, which is actually CPU consumption on the server, not network bandwidth.

UE4 netcode on server has to check each var to see if it requires replicating.

The UE4 server code doing this prevents consumption of bandwidth of all client connections

However, UE4 server doing these calcs for every var does consume a portion of its cpu resources!

And I’ve hit limits with this in real multiplayer games with 4+ people connected in 1 game.

You can do several things to mitigate this and maintain your rep var list, but ultimately I recommend all of the following:

  • Lower the net update rate, which defaults to 100 times per second, for anything that is not a smoothly replicating moving character. You dont have to update an item’s state that is lying still on the ground in the world 100 times per second! Even once per second is a lot for such a thing. Keep in mind you can change the net update rate of an actor via the server any time during its life time!

  • Use actor net dormancy (NetDormancy = DORM_Initial;), which allows you to entirely stop replicating an actor whose state you know you can conditionally update when you need to via FlushNetDormancy.

  • Try to remove use of as many rep vars as you can be extrapolating the state of various things in the game world from information you do already know / from the minimum required number of rep vars. You might be surprised how much you can surmise from already-repped data that can help you avoid repping more stuff

For my own game I actually rolled out my own custom network serialization code path which allows me to skip the rep notify var system entirely for most cases. That is a completely custom solution but my mentioning of it should hopefully give you ideas :slight_smile:

Really ideally you should only be using rep notify for stuff that has to update very frequently :slight_smile:

#:heart:

Rama

Sorry to ask it this way, But I’ve followed your answers around Rama, and I really have found a lot of help in them. I am currently Facing a problem with the UCableComponent. I would appriciate it a lot if you could take a look at it. Thanks you. Here is a link : https://answers.unrealengine.com/questions/441318/ucablecomponent-wont-follow-to-crosshair.html

Hi Rama. Another answer said that you want to call FlushNetDormancy() before you change anything that needs to get sent over. First, is that correct? And second, I wanted to make sure that it’s alright to just call it once and then change a few replicated values (and they will all get sent over). Thanks!