s.AdaptiveAddToWorld.AddToWorldTimeSliceMin
s.AdaptiveAddToWorld.AddToWorldTimeSliceMin
#Overview
name: s.AdaptiveAddToWorld.AddToWorldTimeSliceMin
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Minimum adaptive AddToWorld timeslice
It is referenced in 5
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of s.AdaptiveAddToWorld.AddToWorldTimeSliceMin is to set the minimum time slice for the adaptive AddToWorld process in Unreal Engine 5. This setting is part of the level streaming system, which manages the loading and unloading of levels during gameplay.
The Unreal Engine subsystem that relies on this setting variable is the level streaming system, specifically the adaptive AddToWorld process. This process is responsible for adding actors and components to the game world as levels are loaded.
The value of this variable is set through the console variable system. It is initialized with a default value of 1.0f and can be modified at runtime using console commands.
The associated variable GAdaptiveAddToWorldTimeSliceMin interacts directly with s.AdaptiveAddToWorld.AddToWorldTimeSliceMin. They share the same value, with GAdaptiveAddToWorldTimeSliceMin being the C++ variable used in the engine code.
Developers must be aware that this variable sets a lower bound for the time slice used in the adaptive AddToWorld process. It affects how quickly actors and components are added to the world when loading levels, which can impact performance and loading times.
Best practices when using this variable include:
- Avoid setting it too low, as it might lead to choppy performance during level streaming.
- Balance it with s.AdaptiveAddToWorld.AddToWorldTimeSliceMax for optimal performance.
- Monitor its effects using profiling tools, especially when dealing with large or complex levels.
Regarding the associated variable GAdaptiveAddToWorldTimeSliceMin:
- Its purpose is to store the minimum time slice value for use in the C++ code of the engine.
- It is used directly in the FAdaptiveAddToWorld class, which handles the adaptive time slicing for adding objects to the world.
- The value is set through the console variable system and is used as a lower bound when calculating the adaptive time slice.
- It interacts with GAdaptiveAddToWorldTimeSliceMax to define the range of possible time slice values.
- Developers should be aware that modifying this variable will directly affect the engine’s level streaming performance.
- Best practices include adjusting this value in conjunction with other related variables for optimal level streaming behavior, and thoroughly testing any changes across various scenarios.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/World.cpp:171
Scope: file
Source code excerpt:
static float GAdaptiveAddToWorldTimeSliceMin = 1.0f;
FAutoConsoleVariableRef CVarAdaptiveAddToWorldTimeSliceMin(TEXT("s.AdaptiveAddToWorld.AddToWorldTimeSliceMin"), GAdaptiveAddToWorldTimeSliceMin,
TEXT("Minimum adaptive AddToWorld timeslice"));
static float GAdaptiveAddToWorldTimeSliceMax = 6.0f;
FAutoConsoleVariableRef CVarAdaptiveAddToWorldTimeSliceMax(TEXT("s.AdaptiveAddToWorld.AddToWorldTimeSliceMax"), GAdaptiveAddToWorldTimeSliceMax,
TEXT("Maximum adaptive AddToWorld timeslice"));
#Associated Variable and Callsites
This variable is associated with another variable named GAdaptiveAddToWorldTimeSliceMin
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/World.cpp:170
Scope: file
Source code excerpt:
TEXT("1 - compute the target timeslice based on total work time for levels in flight (this avoids slowing before a level completes)\n"));
static float GAdaptiveAddToWorldTimeSliceMin = 1.0f;
FAutoConsoleVariableRef CVarAdaptiveAddToWorldTimeSliceMin(TEXT("s.AdaptiveAddToWorld.AddToWorldTimeSliceMin"), GAdaptiveAddToWorldTimeSliceMin,
TEXT("Minimum adaptive AddToWorld timeslice"));
static float GAdaptiveAddToWorldTimeSliceMax = 6.0f;
FAutoConsoleVariableRef CVarAdaptiveAddToWorldTimeSliceMax(TEXT("s.AdaptiveAddToWorld.AddToWorldTimeSliceMax"), GAdaptiveAddToWorldTimeSliceMax,
TEXT("Maximum adaptive AddToWorld timeslice"));
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/World.cpp:249
Scope (from outer to inner):
file
class class FAdaptiveAddToWorld
function void EndUpdate
Source code excerpt:
if (ValidFrameCount < HistorySize)
{
BaseTimeSlice = GAdaptiveAddToWorldTimeSliceMin;
ValidFrameCount++;
}
else
{
// Compute the rolling averages
int32 TotalWorkUnits = 0;
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/World.cpp:285
Scope (from outer to inner):
file
class class FAdaptiveAddToWorld
function void EndUpdate
Source code excerpt:
}
float DesiredBaseTimeSlice = FMath::Clamp(TargetTimeSlice, GAdaptiveAddToWorldTimeSliceMin, GAdaptiveAddToWorldTimeSliceMax);
// Limit the timeslice change based on MaxIncreasePerSecond/ MaxReducePerSecond
float NewBaseTimeSlice = DesiredBaseTimeSlice;
if (DesiredBaseTimeSlice > BaseTimeSlice && GAdaptiveAddToWorldTimeSliceMaxIncreasePerSecond > 0.0)
{
NewBaseTimeSlice = FMath::Min(NewBaseTimeSlice, BaseTimeSlice + GAdaptiveAddToWorldTimeSliceMaxIncreasePerSecond * DeltaT);
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/World.cpp:302
Scope (from outer to inner):
file
class class FAdaptiveAddToWorld
function void EndUpdate
Source code excerpt:
else
{
BaseTimeSlice = GAdaptiveAddToWorldTimeSliceMin;
}
CSV_CUSTOM_STAT(LevelStreamingAdaptiveDetail, WorkUnitsProcessedPerSecond, float(WorkUnitsProcessedThisUpdate)/DeltaT, ECsvCustomStatOp::Set);
CSV_CUSTOM_STAT(LevelStreamingAdaptiveDetail, WorkUnitsProcessedThisUpdate, WorkUnitsProcessedThisUpdate, ECsvCustomStatOp::Set);
CSV_CUSTOM_STAT(LevelStreamingAdaptive, TimeSlice, GetTimeSlice(), ECsvCustomStatOp::Set);
CSV_CUSTOM_STAT(LevelStreamingAdaptive, WorkUnitsRemaining, TotalWorkUnitsRemaining, ECsvCustomStatOp::Set);