t.DumpHitches.AllThreads

t.DumpHitches.AllThreads

#Overview

name: t.DumpHitches.AllThreads

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 t.DumpHitches.AllThreads is to control the behavior of the hitch dumping feature in Unreal Engine’s performance monitoring system. It determines whether to dump information from all threads or only the Game and Render threads when a hitch (a momentary pause or stutter in game performance) is detected.

This setting variable is primarily used by the Core module of Unreal Engine, specifically within the Stats subsystem. It’s referenced in the StatsCommand.cpp file, which is part of the performance statistics tracking and reporting system.

The value of this variable is set through the console variable system. It’s defined as a TAutoConsoleVariable with a default value of 0, meaning by default, only the Game and Render threads are dumped.

The associated variable GCVarDumpHitchesAllThreads directly interacts with t.DumpHitches.AllThreads. They share the same value and purpose, with GCVarDumpHitchesAllThreads being the actual console variable object used in the code.

Developers should be aware that changing this variable can significantly affect the amount of data generated when dumping hitches. Setting it to 1 will include information from all threads, which can be more comprehensive but may also generate much larger dump files and potentially impact performance during the dump process.

Best practices when using this variable include:

  1. Keep it at the default value (0) during normal development and gameplay to minimize performance impact.
  2. Set it to 1 when investigating complex performance issues that might involve threads other than Game and Render.
  3. Be prepared to handle larger dump files when set to 1, as it will include data from all threads.
  4. Use in conjunction with other performance monitoring tools for a comprehensive analysis.

Regarding the associated variable GCVarDumpHitchesAllThreads:

The purpose of GCVarDumpHitchesAllThreads is to provide a programmatic interface to the t.DumpHitches.AllThreads setting within the C++ code. It allows the engine to query the current state of this setting and adjust its behavior accordingly.

This variable is used directly in the Core module’s Stats system, specifically in the DumpHitch function. It’s queried to determine whether to dump information from all threads or just the Game and Render threads.

The value of GCVarDumpHitchesAllThreads is set automatically by the console variable system based on the t.DumpHitches.AllThreads setting. Developers typically don’t need to interact with this variable directly in code.

GCVarDumpHitchesAllThreads interacts closely with the hitch detection and dumping system. It’s used to control the behavior of the DumpHitch function.

Developers should be aware that this variable is thread-safe (ECVF_RenderThreadSafe), meaning it can be safely accessed from multiple threads.

Best practices for using GCVarDumpHitchesAllThreads in code include:

  1. Use the GetValueOnAnyThread() method to safely retrieve its value from any thread.
  2. Avoid modifying this variable directly; instead, change the t.DumpHitches.AllThreads console variable.
  3. Consider the performance implications when deciding to dump all threads based on this variable’s value.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/Stats/StatsCommand.cpp:46

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> GCVarDumpHitchesAllThreads(
	TEXT("t.DumpHitches.AllThreads"),
	0,
	TEXT("Dump all Threads when doing stat dumphitches\n")
	TEXT(" 0: Only Game and Render Threads (default)\n")
	TEXT(" 1: All threads"),
	ECVF_RenderThreadSafe
);

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/Stats/StatsCommand.cpp:45

Scope: file

Source code excerpt:

extern CORE_API UE::Tasks::FPipe GStatsPipe;

static TAutoConsoleVariable<int32> GCVarDumpHitchesAllThreads(
	TEXT("t.DumpHitches.AllThreads"),
	0,
	TEXT("Dump all Threads when doing stat dumphitches\n")
	TEXT(" 0: Only Game and Render Threads (default)\n")
	TEXT(" 1: All threads"),
	ECVF_RenderThreadSafe

#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/Stats/StatsCommand.cpp:697

Scope (from outer to inner):

file
function     static void DumpHitch

Source code excerpt:

		FRawStatStackNode* GameThread = NULL;
		FRawStatStackNode* RenderThread = NULL;
		bool bDumpAllThreads = GCVarDumpHitchesAllThreads.GetValueOnAnyThread() != 0;
		for( auto ChildIter = Stack.Children.CreateConstIterator(); ChildIter; ++ChildIter )
		{
			const FName ThreadName = ChildIter.Value()->Meta.NameAndInfo.GetShortName();

			if( ThreadName == FName( NAME_GameThread ) )
			{