demo.UseAdaptiveReplayUpdateFrequency
demo.UseAdaptiveReplayUpdateFrequency
#Overview
name: demo.UseAdaptiveReplayUpdateFrequency
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
If 1, NetUpdateFrequency will be calculated based on how often actors actually write something when recording to a replay
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of demo.UseAdaptiveReplayUpdateFrequency is to control the calculation of NetUpdateFrequency for actors during replay recording in Unreal Engine’s demo system. This setting is primarily used for optimizing network performance in the replay system.
This setting variable is utilized by the demo system, which is part of Unreal Engine’s networking and replay functionality. It is specifically referenced in the DemoNetDriver module, which handles the recording and playback of game replays.
The value of this variable is set as a console variable (CVar) with an initial value of 1. It can be modified at runtime through the console or configuration files.
The associated variable CVarUseAdaptiveReplayUpdateFrequency interacts directly with demo.UseAdaptiveReplayUpdateFrequency, as they share the same value and purpose.
Developers should be aware that when this variable is set to 1 (enabled), the NetUpdateFrequency for actors will be dynamically calculated based on how often actors actually write data during replay recording. This can lead to more efficient use of network resources but may also affect the frequency of updates for certain actors.
Best practices when using this variable include:
- Testing the game thoroughly with both adaptive and fixed update frequencies to ensure optimal performance and gameplay experience.
- Monitoring network performance and adjusting the setting as needed for different game scenarios.
- Considering the impact on gameplay, especially for fast-paced or highly interactive elements that may require more frequent updates.
Regarding the associated variable CVarUseAdaptiveReplayUpdateFrequency:
This is the actual console variable implementation of the demo.UseAdaptiveReplayUpdateFrequency setting. It is defined as a static TAutoConsoleVariable
The value of CVarUseAdaptiveReplayUpdateFrequency is checked in the UDemoNetDriver::TickDemoRecordFrame function, which is responsible for recording demo frames. The adaptive update frequency is applied when the value is greater than 0.
Developers should use CVarUseAdaptiveReplayUpdateFrequency.GetValueOnAnyThread() to retrieve the current value of this setting in their code, ensuring they’re always working with the most up-to-date configuration.
When modifying this variable, developers should consider the potential impact on replay fidelity and network performance, and test thoroughly across various gameplay scenarios to ensure optimal results.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DemoNetDriver.cpp:54
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarDemoFastForwardSkipRepNotifies( TEXT( "demo.FastForwardSkipRepNotifies" ), 1, TEXT( "If true, the driver will optimize fast-forwarding by deferring calls to RepNotify functions until the fast-forward is complete. " ) );
static TAutoConsoleVariable<int32> CVarDemoQueueCheckpointChannels( TEXT( "demo.QueueCheckpointChannels" ), 1, TEXT( "If true, the driver will put all channels created during checkpoint loading into queuing mode, to amortize the cost of spawning new actors across multiple frames." ) );
static TAutoConsoleVariable<int32> CVarUseAdaptiveReplayUpdateFrequency( TEXT( "demo.UseAdaptiveReplayUpdateFrequency" ), 1, TEXT( "If 1, NetUpdateFrequency will be calculated based on how often actors actually write something when recording to a replay" ) );
static TAutoConsoleVariable<int32> CVarDemoAsyncLoadWorld( TEXT( "demo.AsyncLoadWorld" ), 0, TEXT( "If 1, we will use seamless server travel to load the replay world asynchronously" ) );
TAutoConsoleVariable<float> CVarCheckpointUploadDelayInSeconds( TEXT( "demo.CheckpointUploadDelayInSeconds" ), 30.0f, TEXT( "" ) );
static TAutoConsoleVariable<int32> CVarDemoLoadCheckpointGarbageCollect( TEXT( "demo.LoadCheckpointGarbageCollect" ), 1, TEXT("If nonzero, CollectGarbage will be called during LoadCheckpoint after the old actors and connection are cleaned up." ) );
TAutoConsoleVariable<float> CVarCheckpointSaveMaxMSPerFrameOverride( TEXT( "demo.CheckpointSaveMaxMSPerFrameOverride" ), -1.0f, TEXT( "If >= 0, this value will override the CheckpointSaveMaxMSPerFrame member variable, which is the maximum time allowed each frame to spend on saving a checkpoint. If 0, it will save the checkpoint in a single frame, regardless of how long it takes." ) );
TAutoConsoleVariable<int32> CVarDemoClientRecordAsyncEndOfFrame( TEXT( "demo.ClientRecordAsyncEndOfFrame" ), 0, TEXT( "If true, TickFlush will be called on a thread in parallel with Slate." ) );
static TAutoConsoleVariable<int32> CVarForceDisableAsyncPackageMapLoading( TEXT( "demo.ForceDisableAsyncPackageMapLoading" ), 0, TEXT( "If true, async package map loading of network assets will be disabled." ) );
#Associated Variable and Callsites
This variable is associated with another variable named CVarUseAdaptiveReplayUpdateFrequency
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DemoNetDriver.cpp:54
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarDemoFastForwardSkipRepNotifies( TEXT( "demo.FastForwardSkipRepNotifies" ), 1, TEXT( "If true, the driver will optimize fast-forwarding by deferring calls to RepNotify functions until the fast-forward is complete. " ) );
static TAutoConsoleVariable<int32> CVarDemoQueueCheckpointChannels( TEXT( "demo.QueueCheckpointChannels" ), 1, TEXT( "If true, the driver will put all channels created during checkpoint loading into queuing mode, to amortize the cost of spawning new actors across multiple frames." ) );
static TAutoConsoleVariable<int32> CVarUseAdaptiveReplayUpdateFrequency( TEXT( "demo.UseAdaptiveReplayUpdateFrequency" ), 1, TEXT( "If 1, NetUpdateFrequency will be calculated based on how often actors actually write something when recording to a replay" ) );
static TAutoConsoleVariable<int32> CVarDemoAsyncLoadWorld( TEXT( "demo.AsyncLoadWorld" ), 0, TEXT( "If 1, we will use seamless server travel to load the replay world asynchronously" ) );
TAutoConsoleVariable<float> CVarCheckpointUploadDelayInSeconds( TEXT( "demo.CheckpointUploadDelayInSeconds" ), 30.0f, TEXT( "" ) );
static TAutoConsoleVariable<int32> CVarDemoLoadCheckpointGarbageCollect( TEXT( "demo.LoadCheckpointGarbageCollect" ), 1, TEXT("If nonzero, CollectGarbage will be called during LoadCheckpoint after the old actors and connection are cleaned up." ) );
TAutoConsoleVariable<float> CVarCheckpointSaveMaxMSPerFrameOverride( TEXT( "demo.CheckpointSaveMaxMSPerFrameOverride" ), -1.0f, TEXT( "If >= 0, this value will override the CheckpointSaveMaxMSPerFrame member variable, which is the maximum time allowed each frame to spend on saving a checkpoint. If 0, it will save the checkpoint in a single frame, regardless of how long it takes." ) );
TAutoConsoleVariable<int32> CVarDemoClientRecordAsyncEndOfFrame( TEXT( "demo.ClientRecordAsyncEndOfFrame" ), 0, TEXT( "If true, TickFlush will be called on a thread in parallel with Slate." ) );
static TAutoConsoleVariable<int32> CVarForceDisableAsyncPackageMapLoading( TEXT( "demo.ForceDisableAsyncPackageMapLoading" ), 0, TEXT( "If true, async package map loading of network assets will be disabled." ) );
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DemoNetDriver.cpp:2179
Scope (from outer to inner):
file
function void UDemoNetDriver::TickDemoRecordFrame
Source code excerpt:
(
ClientConnection,
CVarUseAdaptiveReplayUpdateFrequency.GetValueOnAnyThread() > 0,
!bDoFindActorChannelEarly,
!bDoCheckDormancyEarly,
MinRecordHz,
MaxRecordHz,
ServerTickTime,
RecordFrameStartTime,