demo.CheckpointSaveMaxMSPerFrameOverride

demo.CheckpointSaveMaxMSPerFrameOverride

#Overview

name: demo.CheckpointSaveMaxMSPerFrameOverride

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

It is referenced in 6 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of demo.CheckpointSaveMaxMSPerFrameOverride is to control the maximum time allowed per frame for saving checkpoints in Unreal Engine’s demo recording system. This setting is part of the replay and demo functionality in the engine.

This setting variable is primarily used in the Engine module, specifically within the demo recording and playback subsystem. It’s referenced in the DemoNetDriver and ReplayHelper classes, which are responsible for managing network demos and replays.

The value of this variable is set as a console variable (CVar) in the engine. It’s initialized with a default value of -1.0f, but can be overridden at runtime through console commands or programmatically.

The associated variable CheckpointSaveMaxMSPerFrame interacts closely with demo.CheckpointSaveMaxMSPerFrameOverride. If the CVar is set to a value greater than or equal to 0, it will override the CheckpointSaveMaxMSPerFrame member variable.

Developers must be aware that:

  1. Setting this variable to 0 will cause the checkpoint to be saved in a single frame, regardless of how long it takes.
  2. A value of -1 (default) means the engine will use the CheckpointSaveMaxMSPerFrame value instead.
  3. This variable can significantly impact performance if not set appropriately, as it directly affects how much time each frame can spend on saving checkpoints.

Best practices when using this variable include:

  1. Only override the default value if you have specific performance requirements or issues.
  2. Monitor performance when adjusting this value, especially in production environments.
  3. Consider the trade-off between smooth gameplay and checkpoint save frequency/completeness.

Regarding the associated variable CheckpointSaveMaxMSPerFrame: This is a config property of the DemoNetDriver class. It serves the same purpose as demo.CheckpointSaveMaxMSPerFrameOverride but is used when the CVar is not set (i.e., when it’s -1). The best practices and considerations for using this variable are similar to those for the CVar. Developers should set this value in the engine configuration based on their specific game requirements and performance targets.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DemoNetDriver.cpp:58

Scope: file

Source code excerpt:

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." ) );
TAutoConsoleVariable<int32> CVarDemoUseNetRelevancy( TEXT( "demo.UseNetRelevancy" ), 0, TEXT( "If 1, will enable relevancy checks and distance culling, using all connected clients as reference." ) );
static TAutoConsoleVariable<float> CVarDemoCullDistanceOverride( TEXT( "demo.CullDistanceOverride" ), 0.0f, TEXT( "If > 0, will represent distance from any viewer where actors will stop being recorded." ) );
static TAutoConsoleVariable<float> CVarDemoRecordHzWhenNotRelevant( TEXT( "demo.RecordHzWhenNotRelevant" ), 2.0f, TEXT( "Record at this frequency when actor is not relevant." ) );
static TAutoConsoleVariable<int32> CVarLoopDemo(TEXT("demo.Loop"), 0, TEXT("<1> : play replay from beginning once it reaches the end / <0> : stop replay at the end"));

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/Engine/DemoNetDriver.h:295

Scope: file

Source code excerpt:

	/**
	 * 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.
	 * See also demo.CheckpointSaveMaxMSPerFrameOverride.
	 */
	UPROPERTY(Config)
	float CheckpointSaveMaxMSPerFrame;

	/** A player controller that this driver should consider its viewpoint for actor prioritization purposes. */
	TWeakObjectPtr<APlayerController> ViewerOverride;

	/** Array of prioritized actors, used in TickDemoRecord. Stored as a member so that its storage doesn't have to be re-allocated each frame. */
	TArray<FDemoActorPriority> PrioritizedActors;

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Public/ReplayHelper.h:101

Scope (from outer to inner):

file
class        class FReplayHelper

Source code excerpt:

	bool ShouldSaveCheckpoint() const;

	/** Returns either CheckpointSaveMaxMSPerFrame or the value of demo.CheckpointSaveMaxMSPerFrameOverride if it's >= 0. */
	float GetCheckpointSaveMaxMSPerFrame() const;

	DECLARE_DELEGATE_OneParam(FOnReplayRecordError, const UE::Net::TNetResult<EReplayResult>&);
	FOnReplayRecordError OnReplayRecordError;

	DECLARE_DELEGATE_OneParam(FOnReplayPlaybackError, const UE::Net::TNetResult<EReplayResult>&);

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DemoNetDriver.cpp:58

Scope: file

Source code excerpt:

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." ) );
TAutoConsoleVariable<int32> CVarDemoUseNetRelevancy( TEXT( "demo.UseNetRelevancy" ), 0, TEXT( "If 1, will enable relevancy checks and distance culling, using all connected clients as reference." ) );
static TAutoConsoleVariable<float> CVarDemoCullDistanceOverride( TEXT( "demo.CullDistanceOverride" ), 0.0f, TEXT( "If > 0, will represent distance from any viewer where actors will stop being recorded." ) );
static TAutoConsoleVariable<float> CVarDemoRecordHzWhenNotRelevant( TEXT( "demo.RecordHzWhenNotRelevant" ), 2.0f, TEXT( "Record at this frequency when actor is not relevant." ) );
static TAutoConsoleVariable<int32> CVarLoopDemo(TEXT("demo.Loop"), 0, TEXT("<1> : play replay from beginning once it reaches the end / <0> : stop replay at the end"));

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/ReplayHelper.cpp:25

Scope: file

Source code excerpt:

extern TAutoConsoleVariable<int32> CVarEnableCheckpoints;
extern TAutoConsoleVariable<float> CVarCheckpointUploadDelayInSeconds;
extern TAutoConsoleVariable<float> CVarCheckpointSaveMaxMSPerFrameOverride;
extern TAutoConsoleVariable<int32> CVarDemoUseNetRelevancy;
extern TAutoConsoleVariable<int32> CVarDemoClientRecordAsyncEndOfFrame;
extern TAutoConsoleVariable<float> CVarDemoRecordHz;
extern TAutoConsoleVariable<float> CVarDemoMinRecordHz;

CSV_DECLARE_CATEGORY_EXTERN(Demo);

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/ReplayHelper.cpp:2116

Scope (from outer to inner):

file
function     float FReplayHelper::GetCheckpointSaveMaxMSPerFrame

Source code excerpt:

float FReplayHelper::GetCheckpointSaveMaxMSPerFrame() const
{
	const float CVarValue = CVarCheckpointSaveMaxMSPerFrameOverride.GetValueOnAnyThread();
	if (CVarValue >= 0.0f)
	{
		return CVarValue;
	}

	return CheckpointSaveMaxMSPerFrame;