tick.AllowAsyncTickCleanup
tick.AllowAsyncTickCleanup
#Overview
name: tick.AllowAsyncTickCleanup
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
If true, ticks are cleaned up in a task thread.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of tick.AllowAsyncTickCleanup is to control whether ticks are cleaned up in a task thread or on the main game thread. This setting variable is part of the Unreal Engine’s tick system, which is responsible for updating game logic and components at regular intervals.
The Unreal Engine’s core engine module relies on this setting variable, specifically within the tick task management system. This can be seen from the file location (Engine/Source/Runtime/Engine/Private/TickTaskManager.cpp) where the variable is defined and used.
The value of this variable is set through a console variable (CVarAllowAsyncTickCleanup) with a default value of 0 (false). This means that by default, tick cleanup is not performed asynchronously.
The associated variable CVarAllowAsyncTickCleanup interacts directly with tick.AllowAsyncTickCleanup. It’s a TAutoConsoleVariable that allows runtime modification of the setting.
Developers must be aware that enabling this variable (setting it to 1 or true) will cause tick cleanup to occur in a separate task thread. This can potentially improve performance by offloading work from the main game thread, but it may also introduce threading complexities and potential race conditions if not handled carefully.
Best practices when using this variable include:
- Thoroughly testing the game with both enabled and disabled states to ensure stability.
- Monitoring performance metrics to determine if async tick cleanup provides a meaningful benefit for your specific game.
- Being cautious when enabling this in projects with complex multi-threaded logic, as it may introduce new synchronization challenges.
Regarding the associated variable CVarAllowAsyncTickCleanup:
The purpose of CVarAllowAsyncTickCleanup is to provide a runtime-configurable interface for the tick.AllowAsyncTickCleanup setting. It allows developers and users to toggle the async tick cleanup feature without recompiling the engine.
This console variable is defined and used within the Engine module, specifically in the tick task management system.
The value of CVarAllowAsyncTickCleanup can be set through the console or configuration files, and it directly controls the behavior of tick cleanup.
CVarAllowAsyncTickCleanup interacts directly with the tick.AllowAsyncTickCleanup setting, essentially serving as its runtime interface.
Developers should be aware that changes to this console variable will take effect immediately, potentially altering the game’s performance characteristics at runtime.
Best practices for using CVarAllowAsyncTickCleanup include:
- Using it for debugging and performance testing purposes.
- Considering exposing it as a configurable option in development builds for easier testing.
- Documenting any performance implications of toggling this variable in your project’s documentation.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/TickTaskManager.cpp:60
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarAllowAsyncTickCleanup(
TEXT("tick.AllowAsyncTickCleanup"),
0,
TEXT("If true, ticks are cleaned up in a task thread."));
static float GTimeguardThresholdMS = 0.0f;
static FAutoConsoleVariableRef CVarLightweightTimeguardThresholdMS(
TEXT("tick.LightweightTimeguardThresholdMS"),
#Associated Variable and Callsites
This variable is associated with another variable named CVarAllowAsyncTickCleanup
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/TickTaskManager.cpp:59
Scope: file
Source code excerpt:
TEXT("If true, ticks are dispatched in a task thread."));
static TAutoConsoleVariable<int32> CVarAllowAsyncTickCleanup(
TEXT("tick.AllowAsyncTickCleanup"),
0,
TEXT("If true, ticks are cleaned up in a task thread."));
static float GTimeguardThresholdMS = 0.0f;
static FAutoConsoleVariableRef CVarLightweightTimeguardThresholdMS(
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/TickTaskManager.cpp:553
Scope (from outer to inner):
file
class class FTickTaskSequencer
function void ReleaseTickGroup
Source code excerpt:
TRACE_CPUPROFILER_EVENT_SCOPE(TickCompletionEvents);
FTaskGraphInterface::Get().WaitUntilTasksComplete(TickCompletionEvents[Block], ENamedThreads::GameThread);
if (SingleThreadedMode() || Block == TG_NewlySpawned || CVarAllowAsyncTickCleanup.GetValueOnGameThread() == 0 || TickCompletionEvents[Block].Num() < 50)
{
ResetTickGroup(Block);
}
else
{
DECLARE_CYCLE_STAT(TEXT("FDelegateGraphTask.ResetTickGroup"), STAT_FDelegateGraphTask_ResetTickGroup, STATGROUP_TaskGraphTasks);