stats.MaxPerGroup

stats.MaxPerGroup

#Overview

name: stats.MaxPerGroup

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 stats.MaxPerGroup is to control the maximum number of lines of stats to show in a group within the Unreal Engine’s stats rendering system. This setting variable is primarily used for performance monitoring and debugging purposes.

The Unreal Engine subsystem that relies on this setting variable is the stats rendering system, which is part of the Engine module. This can be seen from the file path Engine/Source/Runtime/Engine/Private/StatsRender2.cpp.

The value of this variable is set through a console variable (CVar) named CVarNumStatsPerGroup. It is initialized with a default value of 25, as seen in the source code:

TAutoConsoleVariable<int32> CVarNumStatsPerGroup(
    TEXT("stats.MaxPerGroup"),
    25,
    TEXT("The max number of lines of stats to show in a group")
);

The associated variable CVarNumStatsPerGroup interacts directly with stats.MaxPerGroup. They share the same value and purpose.

Developers must be aware that this variable limits the number of stat lines displayed per group. If there are more stats than the specified limit, some information may be hidden from view.

Best practices when using this variable include:

  1. Adjust the value based on the project’s needs and the amount of information that needs to be displayed.
  2. Consider the performance impact of rendering too many stat lines, especially on lower-end devices.
  3. Use in conjunction with other stat-related settings for a comprehensive debugging setup.

Regarding the associated variable CVarNumStatsPerGroup:

The purpose of CVarNumStatsPerGroup is identical to stats.MaxPerGroup. It’s the actual console variable implementation that controls the maximum number of stat lines per group.

This variable is used directly in the stats rendering code, as seen in the RenderArrayOfStats function:

int32 MaxStatsPerGroup = CVarNumStatsPerGroup.GetValueOnGameThread();

The value is retrieved using the GetValueOnGameThread() method, indicating that it’s safe to access from the game thread.

Developers should be aware that changing CVarNumStatsPerGroup at runtime will affect the stats display immediately. This can be useful for dynamically adjusting the level of detail in performance monitoring during development or testing.

Best practices for CVarNumStatsPerGroup include:

  1. Use console commands to adjust the value during runtime for debugging purposes.
  2. Consider exposing this setting in a developer-only UI for easier adjustment during testing.
  3. Be mindful of the performance impact when increasing this value, especially on platforms with limited rendering capabilities.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/StatsRender2.cpp:18

Scope: file

Source code excerpt:


TAutoConsoleVariable<int32> CVarNumStatsPerGroup(
	TEXT("stats.MaxPerGroup"),
	25,
	TEXT("The max number of lines of stats to show in a group")
);

/** Stats rendering constants. */
enum class EStatRenderConsts

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/StatsRender2.cpp:17

Scope: file

Source code excerpt:

#include "GlobalRenderResources.h"

TAutoConsoleVariable<int32> CVarNumStatsPerGroup(
	TEXT("stats.MaxPerGroup"),
	25,
	TEXT("The max number of lines of stats to show in a group")
);

/** Stats rendering constants. */

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/StatsRender2.cpp:724

Scope (from outer to inner):

file
function     void RenderArrayOfStats

Source code excerpt:


	// Render all counters.
	int32 MaxStatsPerGroup = CVarNumStatsPerGroup.GetValueOnGameThread();
	int32 RowIndex;
	for( RowIndex = 0; RowIndex < Aggregates.Num() && RowIndex < MaxStatsPerGroup; ++RowIndex )
	{
		const FComplexStatMessage& ComplexStat = Aggregates[RowIndex];
		const bool bIsBudgetIgnored = IgnoreBudgetStats.Contains(ComplexStat.NameAndInfo.GetShortName());
		if(bBudget && !bIsBudgetIgnored && ComplexStat.NameAndInfo.GetFlag(EStatMetaFlags::IsPackedCCAndDuration))