net.MaxRPCPerNetUpdate
net.MaxRPCPerNetUpdate
#Overview
name: net.MaxRPCPerNetUpdate
The value of this variable can be defined or overridden in .ini config files. 1
.ini config file referencing this setting variable.
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Maximum number of unreliable multicast RPC calls allowed per net update, additional ones will be dropped
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of net.MaxRPCPerNetUpdate is to limit the number of unreliable multicast Remote Procedure Calls (RPCs) allowed per network update in Unreal Engine 5. This setting is primarily used for network optimization and preventing potential network flooding.
This setting variable is relied upon by the Unreal Engine’s networking subsystem, specifically in the replication and RPC handling modules. It’s also used in the GameplayAbilities plugin, indicating its importance in gameplay-related networking.
The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 2, but can be changed at runtime through console commands or configuration files.
The associated variable CVarMaxRPCPerNetUpdate interacts directly with net.MaxRPCPerNetUpdate. They share the same value and purpose, with CVarMaxRPCPerNetUpdate being the actual TAutoConsoleVariable object that stores and manages the setting.
Developers must be aware that this variable can significantly impact network performance and gameplay behavior. Setting it too low might result in important RPCs being dropped, while setting it too high could potentially lead to network congestion.
Best practices when using this variable include:
- Carefully consider the default value (2) and only change it if there’s a specific need.
- Monitor network performance and RPC patterns in your game to determine if adjustments are necessary.
- Use reliable RPCs for critical game information to ensure they’re not dropped due to this limit.
- Consider implementing custom logic to handle cases where RPCs are dropped due to this limit.
Regarding the associated variable CVarMaxRPCPerNetUpdate:
The purpose of CVarMaxRPCPerNetUpdate is to provide programmatic access to the net.MaxRPCPerNetUpdate setting within the C++ code of Unreal Engine.
This variable is used directly in the Engine’s networking code, specifically in the DataReplication module. It’s checked when processing incoming RPCs to determine if the call should be processed or dropped.
The value of CVarMaxRPCPerNetUpdate is set when the net.MaxRPCPerNetUpdate console variable is initialized or changed.
CVarMaxRPCPerNetUpdate interacts closely with the networking systems, particularly in the FObjectReplicator class where it’s used to enforce the RPC limit.
Developers should be aware that changes to CVarMaxRPCPerNetUpdate will directly affect the behavior of net.MaxRPCPerNetUpdate. They should also note that this variable is accessed using the GetValueOnAnyThread() method, which suggests it can be safely read from multiple threads.
Best practices for CVarMaxRPCPerNetUpdate include:
- Use it for read-only purposes in most cases, relying on the console variable system for changes.
- If programmatically changing this value, ensure it’s done in a thread-safe manner and consider the implications on ongoing network operations.
- When accessing the value in performance-critical code, consider caching it locally if it’s accessed frequently, as GetValueOnAnyThread() may have some overhead.
#Setting Variables
#References In INI files
Location: <Workspace>/Projects/Lyra/Config/DefaultEngine.ini:148, section: [ConsoleVariables]
- INI Section:
ConsoleVariables
- Raw value:
10
- Is Array:
False
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DataReplication.cpp:33
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarMaxRPCPerNetUpdate(
TEXT("net.MaxRPCPerNetUpdate"),
2,
TEXT("Maximum number of unreliable multicast RPC calls allowed per net update, additional ones will be dropped"),
ECVF_Default);
static TAutoConsoleVariable<int32> CVarDelayUnmappedRPCs(
TEXT("net.DelayUnmappedRPCs"),
#Loc: <Workspace>/Engine/Plugins/Runtime/GameplayAbilities/Source/GameplayAbilities/Private/GameplayCueManager.cpp:935
Scope (from outer to inner):
file
function void UGameplayCueManager::CheckForTooManyRPCs
Source code excerpt:
if (GameplayCueCheckForTooManyRPCs)
{
static IConsoleVariable* MaxRPCPerNetUpdateCVar = IConsoleManager::Get().FindConsoleVariable(TEXT("net.MaxRPCPerNetUpdate"));
if (MaxRPCPerNetUpdateCVar)
{
AActor* Owner = PendingCue.OwningComponent ? PendingCue.OwningComponent->GetOwner() : nullptr;
UWorld* World = Owner ? Owner->GetWorld() : nullptr;
UNetDriver* NetDriver = World ? World->GetNetDriver() : nullptr;
if (NetDriver)
#Associated Variable and Callsites
This variable is associated with another variable named CVarMaxRPCPerNetUpdate
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DataReplication.cpp:32
Scope: file
Source code excerpt:
DECLARE_CYCLE_STAT(TEXT("ReceiveRPC"), STAT_NetReceiveRPC, STATGROUP_Game);
static TAutoConsoleVariable<int32> CVarMaxRPCPerNetUpdate(
TEXT("net.MaxRPCPerNetUpdate"),
2,
TEXT("Maximum number of unreliable multicast RPC calls allowed per net update, additional ones will be dropped"),
ECVF_Default);
static TAutoConsoleVariable<int32> CVarDelayUnmappedRPCs(
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DataReplication.cpp:2193
Scope (from outer to inner):
file
function bool FObjectReplicator::ReceivedRPC
function void FObjectReplicator::QueueRemoteFunctionBunch
Source code excerpt:
}
if (++RemoteFuncInfo[InfoIdx].Calls > CVarMaxRPCPerNetUpdate.GetValueOnAnyThread())
{
UE_LOG(LogRep, Verbose, TEXT("Too many calls (%d) to RPC %s within a single netupdate. Skipping. %s. LastCallTime: %.2f. CurrentTime: %.2f. LastRelevantTime: %.2f. LastUpdateTime: %.2f "),
RemoteFuncInfo[InfoIdx].Calls, *Func->GetName(), *GetPathNameSafe(GetObject()), RemoteFuncInfo[InfoIdx].LastCallTimestamp, OwningChannel->Connection->Driver->GetElapsedTime(), OwningChannel->RelevantTime, OwningChannel->LastUpdateTime);
// The MustBeMappedGuids can just be dropped, because we aren't actually going to send a bunch. If we don't clear it, then we will get warnings when the next channel tries to replicate
CastChecked<UPackageMapClient>(Connection->PackageMap)->GetMustBeMappedGuidsInLastBunch().Reset();