fx.NiagaraMaxStatInstanceReports

fx.NiagaraMaxStatInstanceReports

#Overview

name: fx.NiagaraMaxStatInstanceReports

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 fx.NiagaraMaxStatInstanceReports is to control the maximum number of different instances from which statistical reports are aggregated in the Niagara visual effects system.

This setting variable is primarily used by the Niagara plugin, which is part of Unreal Engine’s FX (effects) system. Specifically, it’s utilized in the NiagaraCommon module, which handles common functionality for the Niagara system.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 20 but can be changed at runtime using console commands or through configuration files.

The associated variable GNiagaraMaxStatInstanceReports directly interacts with fx.NiagaraMaxStatInstanceReports. They share the same value, with GNiagaraMaxStatInstanceReports being the actual variable used in the C++ code to enforce the limit.

Developers should be aware that this variable limits the number of unique Niagara instances that contribute to statistical reports. If the number of instances exceeds this limit, older data points will be randomly removed to make room for new ones.

Best practices when using this variable include:

  1. Setting an appropriate value based on the scale and complexity of your Niagara effects. Too low a value might not provide enough data for accurate profiling, while too high a value could impact performance.
  2. Monitoring the impact of changes to this value on both the quality of statistical data and overall performance.
  3. Considering adjusting this value dynamically based on the current scene complexity or performance requirements.

Regarding the associated variable GNiagaraMaxStatInstanceReports:

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Plugins/FX/Niagara/Source/Niagara/Private/NiagaraCommon.cpp:51

Scope: file

Source code excerpt:

int32 GNiagaraMaxStatInstanceReports = 20;
FAutoConsoleVariableRef CVarMaxStatInstanceReportss(
    TEXT("fx.NiagaraMaxStatInstanceReports"),
    GNiagaraMaxStatInstanceReports,
    TEXT("The max number of different instances from which stat reports are aggregated."),
    ECVF_Default);

static int32 GbMaxStatRecordedFrames = 30;
static FAutoConsoleVariableRef CVarMaxStatRecordedFrames(

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Plugins/FX/Niagara/Source/Niagara/Private/NiagaraCommon.cpp:49

Scope: file

Source code excerpt:

);

int32 GNiagaraMaxStatInstanceReports = 20;
FAutoConsoleVariableRef CVarMaxStatInstanceReportss(
    TEXT("fx.NiagaraMaxStatInstanceReports"),
    GNiagaraMaxStatInstanceReports,
    TEXT("The max number of different instances from which stat reports are aggregated."),
    ECVF_Default);

static int32 GbMaxStatRecordedFrames = 30;
static FAutoConsoleVariableRef CVarMaxStatRecordedFrames(
    TEXT("fx.Niagara.MaxStatRecordedFrames"),

#Loc: <Workspace>/Engine/Plugins/FX/Niagara/Source/Niagara/Private/NiagaraCommon.cpp:345

Scope (from outer to inner):

file
function     void FNiagaraStatDatabase::AddStatCapture

Source code excerpt:

	}
	FScopeLock Lock(GetCriticalSection());
	if (StatCaptures.Num() > GNiagaraMaxStatInstanceReports)
	{
		// we don't need data from too many emitter instances. If we already have enough, delete an old data point.
		TArray<FStatReportKey> Keys;
		StatCaptures.GetKeys(Keys);
		StatCaptures.Remove(Keys[FMath::RandHelper(Keys.Num())]);
	}