DumpStatPackets

DumpStatPackets

#Overview

name: DumpStatPackets

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 DumpStatPackets is to control the logging of stat packets in Unreal Engine’s statistics system. It is used for debugging and performance analysis purposes.

This setting variable is primarily used in the Core module of Unreal Engine, specifically in the statistics subsystem. Based on the callsites, it’s part of the Stats2.cpp file, which suggests it’s related to the engine’s statistics gathering and reporting functionality.

The value of this variable is set through a console variable (CVar) system. It’s defined as a TAutoConsoleVariable with an initial value of 0, meaning it’s disabled by default. Users can change this value at runtime through the console or configuration files.

The associated variable CVarDumpStatPackets directly interacts with DumpStatPackets. They share the same value and purpose.

Developers should be aware that enabling this variable (setting it to a non-zero value) will cause the engine to log information about stat packets. This can be useful for debugging but may impact performance if left enabled in a release build.

Best practices when using this variable include:

  1. Only enable it when necessary for debugging or performance analysis.
  2. Remember to disable it after use, especially before building for release.
  3. Be cautious about enabling it in performance-critical scenarios, as it may introduce overhead.

Regarding the associated variable CVarDumpStatPackets:

The purpose of CVarDumpStatPackets is identical to DumpStatPackets. It’s the actual console variable implementation that controls the stat packet dumping functionality.

This variable is used in the FStatsThread class, specifically in the StatMessage function. When enabled, it logs information about incoming stat packets, including the thread ID and the number of messages in the packet.

The value of CVarDumpStatPackets is set through the console variable system and can be accessed using the GetValueOnAnyThread() method.

Developers should be aware that this variable is checked in performance-sensitive code paths related to stats processing. Enabling it may have a performance impact, especially in scenarios with high volumes of stat packets.

Best practices for using CVarDumpStatPackets include:

  1. Use it judiciously, only when detailed stats debugging is necessary.
  2. Consider the performance implications when enabling it, especially in production environments.
  3. Use the console command system to toggle it on and off as needed during development and debugging sessions.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/Stats/Stats2.cpp:903

Scope: file

Source code excerpt:

-----------------------------------------------------------------------------*/

static TAutoConsoleVariable<int32> CVarDumpStatPackets(	TEXT("DumpStatPackets"),0,	TEXT("If true, dump stat packets."));

/** The rendering thread runnable object. */
class FStatsThread
{
	/** Array of stat packets, queued data to be processed on this thread. */
	FStatPacketArray IncomingData;

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/Stats/Stats2.cpp:903

Scope: file

Source code excerpt:

-----------------------------------------------------------------------------*/

static TAutoConsoleVariable<int32> CVarDumpStatPackets(	TEXT("DumpStatPackets"),0,	TEXT("If true, dump stat packets."));

/** The rendering thread runnable object. */
class FStatsThread
{
	/** Array of stat packets, queued data to be processed on this thread. */
	FStatPacketArray IncomingData;

#Loc: <Workspace>/Engine/Source/Runtime/Core/Private/Stats/Stats2.cpp:936

Scope (from outer to inner):

file
class        class FStatsThread
function     void StatMessage

Source code excerpt:

		LLM_SCOPE(ELLMTag::Stats);

		if (CVarDumpStatPackets.GetValueOnAnyThread())
		{
			UE_LOG(LogStats, Log, TEXT("Packet from %x with %d messages"), Packet->ThreadId, Packet->StatMessages.Num());
		}

		bReadyToProcess = Packet->ThreadType != EThreadType::Other;
		IncomingData.Packets.Add(Packet);