net.SkipReplicatorForDestructionInfos

net.SkipReplicatorForDestructionInfos

#Overview

name: net.SkipReplicatorForDestructionInfos

This variable is created as a Console Variable (cvar).

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of net.SkipReplicatorForDestructionInfos is to optimize network performance by skipping the creation of object replicators for actors that are about to be destroyed. This setting is part of Unreal Engine’s networking subsystem.

This setting variable is primarily used in the Engine module, specifically within the networking code responsible for handling actor replication and destruction.

The value of this variable is set through a console variable (CVar) system. It’s initialized to 1 (enabled) by default in the Engine/Source/Runtime/Engine/Private/DataChannel.cpp file.

The associated variable GSkipReplicatorForDestructionInfos directly interacts with net.SkipReplicatorForDestructionInfos. They share the same value, with GSkipReplicatorForDestructionInfos being the actual integer variable used in the code.

Developers must be aware that enabling this variable (which is the default behavior) will skip the creation of object replicators for actors that are about to be destroyed. This can improve network performance by reducing unnecessary network traffic, but it may have implications for certain game logic that relies on replication of destruction information.

Best practices when using this variable include:

  1. Ensuring that skipping replicator creation for soon-to-be-destroyed actors doesn’t break any game-specific logic.
  2. Monitoring network performance to confirm the positive impact of this optimization.
  3. Testing thoroughly with this setting both enabled and disabled to ensure game behavior remains consistent.

Regarding the associated variable GSkipReplicatorForDestructionInfos:

The purpose of GSkipReplicatorForDestructionInfos is to provide a runtime-accessible integer that reflects the state of the net.SkipReplicatorForDestructionInfos setting.

This variable is used in the Engine module, specifically in the UActorChannel::ProcessBunch function, to determine whether to skip replicator creation for actors that are about to be destroyed.

The value of GSkipReplicatorForDestructionInfos is set through the CVar system, mirroring the value of net.SkipReplicatorForDestructionInfos.

GSkipReplicatorForDestructionInfos directly interacts with the ESetChannelActorFlags enum, influencing the behavior of the SetChannelActor function.

Developers should be aware that this variable is checked in performance-critical networking code, so changing its value at runtime could have immediate effects on network behavior.

Best practices for using GSkipReplicatorForDestructionInfos include:

  1. Avoiding frequent changes to this variable during gameplay, as it could lead to inconsistent network behavior.
  2. Using it in conjunction with proper network debugging tools to understand its impact on replication.
  3. Considering the implications on custom network code that might rely on replicator creation for soon-to-be-destroyed actors.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DataChannel.cpp:91

Scope: file

Source code excerpt:

int32 GSkipReplicatorForDestructionInfos = 1;
FAutoConsoleVariableRef CVarNetSkipReplicatorForDestructionInfos(
	TEXT("net.SkipReplicatorForDestructionInfos"),
	GSkipReplicatorForDestructionInfos,
	TEXT("If enabled, skip creation of object replicator in SetChannelActor when we know there is no content payload and we're going to immediately destroy the actor."));

// Fairly large number, and probably a bad idea to even have a bunch this size, but want to be safe for now and not throw out legitimate data
static int32 NetMaxConstructedPartialBunchSizeBytes = 1024 * 64;
static FAutoConsoleVariableRef CVarNetMaxConstructedPartialBunchSizeBytes(

#Associated Variable and Callsites

This variable is associated with another variable named GSkipReplicatorForDestructionInfos. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DataChannel.cpp:89

Scope: file

Source code excerpt:

	TEXT("If a bunch is broken up into this many partial bunches are more, we will send it reliable even if the original bunch was not reliable. Partial bunches are atonmic and must all make it over to be used"));

int32 GSkipReplicatorForDestructionInfos = 1;
FAutoConsoleVariableRef CVarNetSkipReplicatorForDestructionInfos(
	TEXT("net.SkipReplicatorForDestructionInfos"),
	GSkipReplicatorForDestructionInfos,
	TEXT("If enabled, skip creation of object replicator in SetChannelActor when we know there is no content payload and we're going to immediately destroy the actor."));

// Fairly large number, and probably a bad idea to even have a bunch this size, but want to be safe for now and not throw out legitimate data
static int32 NetMaxConstructedPartialBunchSizeBytes = 1024 * 64;
static FAutoConsoleVariableRef CVarNetMaxConstructedPartialBunchSizeBytes(
	TEXT("net.MaxConstructedPartialBunchSizeBytes"),

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DataChannel.cpp:3172

Scope (from outer to inner):

file
function     void UActorChannel::ProcessBunch

Source code excerpt:


		ESetChannelActorFlags Flags = ESetChannelActorFlags::None;
		if (GSkipReplicatorForDestructionInfos != 0 && Bunch.bClose && Bunch.AtEnd())
		{
			Flags |= ESetChannelActorFlags::SkipReplicatorCreation;
		}

		UE_LOG(LogNetTraffic, Log, TEXT("      Channel Actor %s:"), *NewChannelActor->GetFullName());
		SetChannelActor(NewChannelActor, Flags);