LogGameThreadFNameChurn.SampleFrequency

LogGameThreadFNameChurn.SampleFrequency

#Overview

name: LogGameThreadFNameChurn.SampleFrequency

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

It is referenced in 5 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of LogGameThreadFNameChurn.SampleFrequency is to control the sampling frequency for monitoring FName creation churn on the game thread. It is used to balance performance impact with the need for tracking FName creation.

This setting variable is primarily used in the Core module of Unreal Engine, specifically in the UnrealNames.cpp file, which is part of the UObject system. It’s used to manage the performance impact of tracking FName creation churn.

The value of this variable is set through the console variable system (CVar) in Unreal Engine. It’s defined as a TAutoConsoleVariable with an initial value of 1, but can be changed at runtime through console commands or configuration files.

This variable interacts closely with several other variables related to FName churn tracking, such as CVarLogGameThreadFNameChurn_PrintFrequency and CVarLogGameThreadFNameChurn_Threshhold. It’s directly associated with CVarLogGameThreadFNameChurn_SampleFrequency, which is the C++ variable that holds its value.

Developers should be aware that:

  1. Increasing this value will reduce the performance impact of FName churn tracking but may miss some FName creations.
  2. Decreasing this value will provide more accurate tracking but may impact game performance.

Best practices when using this variable include:

  1. Adjust it based on the needs of your project - higher values for production builds, lower values for debugging.
  2. Use it in conjunction with other FName churn tracking variables for a comprehensive view of FName usage.
  3. Monitor its impact on performance, especially when set to low values.

Regarding CVarLogGameThreadFNameChurn_SampleFrequency: This is the C++ variable that directly holds the value of LogGameThreadFNameChurn.SampleFrequency. It’s used in the NameCreationHook function to determine how often to collect samples and in the PrintResultsAndReset function to calculate the correction factor for the sample frequency. The same considerations and best practices apply to this variable as to LogGameThreadFNameChurn.SampleFrequency.

#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:5238

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarLogGameThreadFNameChurn_SampleFrequency(
	TEXT("LogGameThreadFNameChurn.SampleFrequency"),
	1,
	TEXT("Number of fname creates per sample. This is used to prevent churn sampling from slowing the game down too much."));

static TAutoConsoleVariable<int32> CVarLogGameThreadFNameChurn_StackIgnore(
	TEXT("LogGameThreadFNameChurn.StackIgnore"),
	4,

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/UObject/UnrealNames.cpp:5237

Scope: file

Source code excerpt:

	TEXT("Minimum average number of fname creations per frame to include in the report."));

static TAutoConsoleVariable<int32> CVarLogGameThreadFNameChurn_SampleFrequency(
	TEXT("LogGameThreadFNameChurn.SampleFrequency"),
	1,
	TEXT("Number of fname creates per sample. This is used to prevent churn sampling from slowing the game down too much."));

static TAutoConsoleVariable<int32> CVarLogGameThreadFNameChurn_StackIgnore(
	TEXT("LogGameThreadFNameChurn.StackIgnore"),

#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/UObject/UnrealNames.cpp:5281

Scope (from outer to inner):

file
function     void NameCreationHook

Source code excerpt:

			if (bEnabled)
			{
				CountDown = CVarLogGameThreadFNameChurn_SampleFrequency.GetValueOnGameThread();
				DumpFrame = GFrameCounter + CVarLogGameThreadFNameChurn_PrintFrequency.GetValueOnGameThread();
				GGameThreadFNameChurnTracker.ResetTracking();
				GGameThreadFNameChurnTracker.ToggleTracking(true, true);
			}
			else
			{

#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/UObject/UnrealNames.cpp:5299

Scope (from outer to inner):

file
function     void NameCreationHook

Source code excerpt:

			if (--CountDown <= 0)
			{
				CountDown = CVarLogGameThreadFNameChurn_SampleFrequency.GetValueOnGameThread();
				CollectSample();
				if (GFrameCounter > DumpFrame)
				{
					PrintResultsAndReset();
				}
			}

#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/UObject/UnrealNames.cpp:5318

Scope (from outer to inner):

file
function     void PrintResultsAndReset

Source code excerpt:

		DumpFrame = GFrameCounter + CVarLogGameThreadFNameChurn_PrintFrequency.GetValueOnGameThread();
		FOutputDeviceRedirector* Log = FOutputDeviceRedirector::Get();
		float SampleAndFrameCorrection = float(CVarLogGameThreadFNameChurn_SampleFrequency.GetValueOnGameThread()) / float(CVarLogGameThreadFNameChurn_PrintFrequency.GetValueOnGameThread());
		GGameThreadFNameChurnTracker.DumpStackTraces(CVarLogGameThreadFNameChurn_Threshhold.GetValueOnGameThread(), *Log, SampleAndFrameCorrection);
		GGameThreadFNameChurnTracker.ResetTracking();
	}
};

FSampleFNameChurn GGameThreadFNameChurnTracker;