s.AdaptiveAddToWorld.AddToWorldTimeSliceMax

s.AdaptiveAddToWorld.AddToWorldTimeSliceMax

#Overview

name: s.AdaptiveAddToWorld.AddToWorldTimeSliceMax

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

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of s.AdaptiveAddToWorld.AddToWorldTimeSliceMax is to set the maximum time slice for the adaptive AddToWorld process in Unreal Engine 5. This setting is part of the engine’s world management and performance optimization system.

This setting variable is primarily used in the Engine module, specifically within the World.cpp file. It’s part of the adaptive AddToWorld system, which manages how objects are added to the game world over time to balance performance.

The value of this variable is set through the console variable system. It’s initialized with a default value of 6.0 seconds and can be modified at runtime using console commands or through configuration files.

The variable interacts closely with other adaptive AddToWorld settings, particularly:

  1. GAdaptiveAddToWorldTimeSliceMin (minimum time slice)
  2. GAdaptiveAddToWorldTargetMaxTimeRemaining (target maximum remaining time)
  3. GAdaptiveAddToWorldTimeSliceMaxIncreasePerSecond (maximum increase rate per second)

Developers should be aware that this variable sets an upper limit on how much time can be allocated to the AddToWorld process in a single frame. Setting it too high might lead to frame rate drops, while setting it too low might cause objects to be added to the world too slowly.

Best practices when using this variable include:

  1. Balancing it with the minimum time slice for smooth performance
  2. Adjusting it based on the complexity of your world and the number of objects being added
  3. Monitoring its impact on frame rates and loading times
  4. Using it in conjunction with other adaptive AddToWorld settings for optimal performance

Regarding the associated variable GAdaptiveAddToWorldTimeSliceMax:

This is the actual C++ variable that stores the value set by s.AdaptiveAddToWorld.AddToWorldTimeSliceMax. It’s used directly in the engine code to control the adaptive AddToWorld process.

The purpose of GAdaptiveAddToWorldTimeSliceMax is to provide a programmatic way to access and modify the maximum time slice value within the C++ code of the engine.

This variable is used in the Engine module, specifically in the FAdaptiveAddToWorld class, which manages the adaptive AddToWorld process.

Its value is set through the console variable system, allowing for runtime modification.

GAdaptiveAddToWorldTimeSliceMax interacts with other variables in the adaptive AddToWorld system, particularly in the clamping operation where it’s used as the upper bound.

Developers should be aware that modifying this variable directly in C++ code will affect the engine’s behavior, potentially impacting performance and object loading times.

Best practices for using GAdaptiveAddToWorldTimeSliceMax include:

  1. Avoiding direct modification unless absolutely necessary
  2. Using the console variable system for adjustments during development and testing
  3. Documenting any custom modifications for easier maintenance and debugging

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/World.cpp:175

Scope: file

Source code excerpt:


static float GAdaptiveAddToWorldTimeSliceMax = 6.0f;
FAutoConsoleVariableRef CVarAdaptiveAddToWorldTimeSliceMax(TEXT("s.AdaptiveAddToWorld.AddToWorldTimeSliceMax"), GAdaptiveAddToWorldTimeSliceMax, 
	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"));

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/World.cpp:174

Scope: file

Source code excerpt:

	TEXT("Minimum adaptive AddToWorld timeslice"));

static float GAdaptiveAddToWorldTimeSliceMax = 6.0f;
FAutoConsoleVariableRef CVarAdaptiveAddToWorldTimeSliceMax(TEXT("s.AdaptiveAddToWorld.AddToWorldTimeSliceMax"), GAdaptiveAddToWorldTimeSliceMax, 
	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"));

#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);