LogGameThreadFNameChurn.Enable
LogGameThreadFNameChurn.Enable
#Overview
name: LogGameThreadFNameChurn.Enable
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
If > 0, then collect sample game thread fname create, periodically print a report of the worst offenders.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of LogGameThreadFNameChurn.Enable is to enable logging and tracking of FName (string) creation on the game thread. It is designed to help developers identify and optimize excessive FName creation, which can impact performance.
This setting variable is primarily used in the Core module of Unreal Engine, specifically in the UnrealNames system. It’s part of the engine’s performance profiling and optimization tools.
The value of this variable is set through the console variable system. It’s defined as a TAutoConsoleVariable with a default value of 0 (disabled). Developers can change this value at runtime using console commands or through configuration files.
LogGameThreadFNameChurn.Enable interacts with another console variable, LogGameThreadFNameChurn.PrintFrequency, which determines how often the collected data is printed.
Developers should be aware that enabling this variable will incur some performance overhead due to the additional tracking and logging. It should primarily be used for debugging and optimization purposes, not in shipping builds.
Best practices for using this variable include:
- Enable it only when investigating FName creation issues.
- Use it in conjunction with LogGameThreadFNameChurn.PrintFrequency to control output frequency.
- Analyze the output to identify areas of code that are creating excessive FNames.
- Optimize the identified areas by reducing FName creation or caching frequently used FNames.
Regarding the associated variable CVarLogGameThreadFNameChurn:
The purpose of CVarLogGameThreadFNameChurn is to serve as the actual console variable that controls the LogGameThreadFNameChurn.Enable setting. It’s an internal implementation detail that allows the engine to interact with the console variable system.
This variable is used in the Core module, specifically in the UnrealNames system. Its value is set through the console variable system, just like LogGameThreadFNameChurn.Enable.
CVarLogGameThreadFNameChurn directly interacts with the NameCreationHook function, which enables or disables the FName creation tracking based on its value.
Developers should be aware that this is the actual variable being checked in the code, so any runtime changes to LogGameThreadFNameChurn.Enable will affect this variable.
The best practice is to interact with LogGameThreadFNameChurn.Enable rather than CVarLogGameThreadFNameChurn directly, as the former is the intended interface for this functionality.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/UObject/UnrealNames.cpp:5223
Scope: file
Source code excerpt:
#include "Containers/StackTracker.h"
static TAutoConsoleVariable<int32> CVarLogGameThreadFNameChurn(
TEXT("LogGameThreadFNameChurn.Enable"),
0,
TEXT("If > 0, then collect sample game thread fname create, periodically print a report of the worst offenders."));
static TAutoConsoleVariable<int32> CVarLogGameThreadFNameChurn_PrintFrequency(
TEXT("LogGameThreadFNameChurn.PrintFrequency"),
300,
#Associated Variable and Callsites
This variable is associated with another variable named CVarLogGameThreadFNameChurn
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/UObject/UnrealNames.cpp:5222
Scope: file
Source code excerpt:
#include "Containers/StackTracker.h"
static TAutoConsoleVariable<int32> CVarLogGameThreadFNameChurn(
TEXT("LogGameThreadFNameChurn.Enable"),
0,
TEXT("If > 0, then collect sample game thread fname create, periodically print a report of the worst offenders."));
static TAutoConsoleVariable<int32> CVarLogGameThreadFNameChurn_PrintFrequency(
TEXT("LogGameThreadFNameChurn.PrintFrequency"),
#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/UObject/UnrealNames.cpp:5274
Scope (from outer to inner):
file
function void NameCreationHook
Source code excerpt:
void NameCreationHook()
{
bool bNewEnabled = CVarLogGameThreadFNameChurn.GetValueOnGameThread() > 0;
if (bNewEnabled != bEnabled)
{
check(IsInGameThread());
bEnabled = bNewEnabled;
if (bEnabled)
{