s.AdaptiveAddToWorld.TargetMaxTimeRemaining
s.AdaptiveAddToWorld.TargetMaxTimeRemaining
#Overview
name: s.AdaptiveAddToWorld.TargetMaxTimeRemaining
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Target max time remaining in seconds. If our estimated completion time is longer than this, the timeslice will increase. Lower values are more aggressive
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of s.AdaptiveAddToWorld.TargetMaxTimeRemaining is to control the adaptive behavior of the AddToWorld process in Unreal Engine’s level streaming system. It sets a target maximum time remaining for completing the addition of new levels to the game world.
This setting variable is primarily used by the Engine module, specifically in the level streaming subsystem. It’s part of the adaptive loading mechanism that adjusts the time slice allocated for adding new levels to the world based on performance requirements.
The value of this variable is set through the console variable system. It’s initialized with a default value of 6.0 seconds but can be changed at runtime using console commands or through configuration files.
The associated variable GAdaptiveAddToWorldTargetMaxTimeRemaining directly interacts with s.AdaptiveAddToWorld.TargetMaxTimeRemaining. They share the same value, with the console variable acting as an interface for runtime adjustments.
Developers should be aware that this variable significantly impacts the responsiveness of level streaming. A lower value will make the system more aggressive in allocating time for adding new levels, potentially improving loading times but at the cost of increased CPU usage during streaming.
Best practices when using this variable include:
- Adjusting it based on the specific needs of your game and target hardware.
- Testing different values to find the right balance between loading speed and performance impact.
- Considering the complexity and size of your levels when setting this value.
- Using it in conjunction with other adaptive loading settings for optimal results.
Regarding the associated variable GAdaptiveAddToWorldTargetMaxTimeRemaining:
Its purpose is to store the actual value used by the engine for calculations. It’s used directly in the FAdaptiveAddToWorld class to compute the target time slice for adding levels to the world.
This variable is part of the Engine module and is crucial for the adaptive level streaming system.
Its value is set by the console variable system, allowing for runtime adjustments.
It interacts closely with other adaptive loading variables like GAdaptiveAddToWorldTimeSliceMin and GAdaptiveAddToWorldTimeSliceMax to determine the appropriate time slice for level loading.
Developers should be aware that changes to this variable will directly affect the behavior of the adaptive loading system. It’s used in calculations that determine how aggressively the engine will try to complete level loading.
Best practices include monitoring its effect on performance and adjusting it alongside other related variables for optimal loading behavior in your specific game scenario.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/World.cpp:179
Scope: file
Source code excerpt:
static float GAdaptiveAddToWorldTargetMaxTimeRemaining = 6.0f;
FAutoConsoleVariableRef CVarAdaptiveAddToWorldTargetMaxTimeRemaining(TEXT("s.AdaptiveAddToWorld.TargetMaxTimeRemaining"), GAdaptiveAddToWorldTargetMaxTimeRemaining,
TEXT("Target max time remaining in seconds. If our estimated completion time is longer than this, the timeslice will increase. Lower values are more aggressive"));
static float GAdaptiveAddToWorldTimeSliceMaxIncreasePerSecond = 0.0f;
FAutoConsoleVariableRef CVarAdaptiveAddToWorldTimeSliceMaxIncreasePerSecond(TEXT("s.AdaptiveAddToWorld.TimeSliceMaxIncreasePerSecond"), GAdaptiveAddToWorldTimeSliceMaxIncreasePerSecond,
TEXT("Max rate at which the adptive AddToWorld timeslice will increase. Set to 0 to increase instantly"));
#Associated Variable and Callsites
This variable is associated with another variable named GAdaptiveAddToWorldTargetMaxTimeRemaining
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/World.cpp:178
Scope: file
Source code excerpt:
TEXT("Maximum adaptive AddToWorld timeslice"));
static float GAdaptiveAddToWorldTargetMaxTimeRemaining = 6.0f;
FAutoConsoleVariableRef CVarAdaptiveAddToWorldTargetMaxTimeRemaining(TEXT("s.AdaptiveAddToWorld.TargetMaxTimeRemaining"), GAdaptiveAddToWorldTargetMaxTimeRemaining,
TEXT("Target max time remaining in seconds. If our estimated completion time is longer than this, the timeslice will increase. Lower values are more aggressive"));
static float GAdaptiveAddToWorldTimeSliceMaxIncreasePerSecond = 0.0f;
FAutoConsoleVariableRef CVarAdaptiveAddToWorldTimeSliceMaxIncreasePerSecond(TEXT("s.AdaptiveAddToWorld.TimeSliceMaxIncreasePerSecond"), GAdaptiveAddToWorldTimeSliceMaxIncreasePerSecond,
TEXT("Max rate at which the adptive AddToWorld timeslice will increase. Set to 0 to increase instantly"));
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/World.cpp:276
Scope (from outer to inner):
file
class class FAdaptiveAddToWorld
function void EndUpdate
Source code excerpt:
float EstimatedTotalTimeForCurrentLevelsWith1MsTimeSlice = (float)TotalWorkUnitsForLevelsInFlight / AverageWorkUnitsPerSecondWith1MsTimeSlice;
CSV_CUSTOM_STAT(LevelStreamingAdaptiveDetail, EstimatedTotalTimeForCurrentLevelsWith1MsTimeSlice, EstimatedTotalTimeForCurrentLevelsWith1MsTimeSlice, ECsvCustomStatOp::Set);
TargetTimeSlice = EstimatedTotalTimeForCurrentLevelsWith1MsTimeSlice / GAdaptiveAddToWorldTargetMaxTimeRemaining - ExtraTimeSlice;
}
else
{
float EstimatedTimeRemainingWith1MsTimeSlice = (float)TotalWorkUnitsRemaining / AverageWorkUnitsPerSecondWith1MsTimeSlice;
CSV_CUSTOM_STAT(LevelStreamingAdaptiveDetail, EstimatedTimeRemainingWith1MsTimeSlice, EstimatedTimeRemainingWith1MsTimeSlice, ECsvCustomStatOp::Set);
TargetTimeSlice = EstimatedTimeRemainingWith1MsTimeSlice / GAdaptiveAddToWorldTargetMaxTimeRemaining - ExtraTimeSlice;
}
float DesiredBaseTimeSlice = FMath::Clamp(TargetTimeSlice, GAdaptiveAddToWorldTimeSliceMin, GAdaptiveAddToWorldTimeSliceMax);
// Limit the timeslice change based on MaxIncreasePerSecond/ MaxReducePerSecond
float NewBaseTimeSlice = DesiredBaseTimeSlice;