LogGameThreadFNameChurn.StackLen
LogGameThreadFNameChurn.StackLen
#Overview
name: LogGameThreadFNameChurn.StackLen
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Maximum number of stack frame items to keep. This improves aggregation because calls that originate from multiple places but end up in the same place will be accounted together.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of LogGameThreadFNameChurn.StackLen is to control the maximum number of stack frame items to keep when tracking FName churn (creation and destruction) on the game thread. This setting is primarily used for performance profiling and debugging purposes within the Unreal Engine’s core name system.
This setting variable is mainly used in the Core module of Unreal Engine, specifically in the name handling system. It’s part of a broader feature for monitoring and analyzing FName allocations and deallocations, which can be crucial for optimizing game performance.
The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 3, but can be changed at runtime through console commands or configuration files.
The associated variable CVarLogGameThreadFNameChurn_StackLen directly interacts with LogGameThreadFNameChurn.StackLen. They share the same value and purpose.
Developers must be aware that:
- This setting affects the granularity of FName churn tracking. A higher value provides more detailed stack traces but may increase memory usage and slightly impact performance during profiling.
- The value influences how calls are aggregated. Calls originating from different places but ending in the same place will be grouped together, which can help identify common sources of FName churn.
Best practices when using this variable include:
- Start with the default value (3) and adjust as needed based on the level of detail required for your profiling needs.
- Use in conjunction with other FName churn tracking settings for a comprehensive view of name system performance.
- Be mindful of potential performance impacts when setting to very high values, especially in production builds.
Regarding the associated variable CVarLogGameThreadFNameChurn_StackLen: Its purpose is identical to LogGameThreadFNameChurn.StackLen, serving as the actual console variable that controls the stack length for FName churn tracking.
This variable is used in the Core module, specifically in the name handling system for performance profiling.
Its value is set through the console variable system and can be changed at runtime.
It directly interacts with LogGameThreadFNameChurn.StackLen, effectively controlling the same setting.
Developers should be aware that this is the actual variable used in the code to retrieve the current stack length setting. It’s accessed using GetValueOnGameThread() method.
Best practices include using this variable consistently throughout the codebase when referring to the stack length setting for FName churn tracking, and considering its value when analyzing profiling results.
#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:5253
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarLogGameThreadFNameChurn_StackLen(
TEXT("LogGameThreadFNameChurn.StackLen"),
3,
TEXT("Maximum number of stack frame items to keep. This improves aggregation because calls that originate from multiple places but end up in the same place will be accounted together."));
struct FSampleFNameChurn
{
#Associated Variable and Callsites
This variable is associated with another variable named CVarLogGameThreadFNameChurn_StackLen
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/UObject/UnrealNames.cpp:5252
Scope: file
Source code excerpt:
TEXT("If > 0 then remove aliases from the counting process. This essentialy merges addresses that have the same human readable string. It is slower."));
static TAutoConsoleVariable<int32> CVarLogGameThreadFNameChurn_StackLen(
TEXT("LogGameThreadFNameChurn.StackLen"),
3,
TEXT("Maximum number of stack frame items to keep. This improves aggregation because calls that originate from multiple places but end up in the same place will be accounted together."));
struct FSampleFNameChurn
#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/UObject/UnrealNames.cpp:5312
Scope (from outer to inner):
file
function void CollectSample
Source code excerpt:
{
check(IsInGameThread());
GGameThreadFNameChurnTracker.CaptureStackTrace(CVarLogGameThreadFNameChurn_StackIgnore.GetValueOnGameThread(), nullptr, CVarLogGameThreadFNameChurn_StackLen.GetValueOnGameThread(), CVarLogGameThreadFNameChurn_RemoveAliases.GetValueOnGameThread() > 0);
}
void PrintResultsAndReset()
{
DumpFrame = GFrameCounter + CVarLogGameThreadFNameChurn_PrintFrequency.GetValueOnGameThread();
FOutputDeviceRedirector* Log = FOutputDeviceRedirector::Get();
float SampleAndFrameCorrection = float(CVarLogGameThreadFNameChurn_SampleFrequency.GetValueOnGameThread()) / float(CVarLogGameThreadFNameChurn_PrintFrequency.GetValueOnGameThread());