PerfWarn.CoarseSampleTime

PerfWarn.CoarseSampleTime

#Overview

name: PerfWarn.CoarseSampleTime

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

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of PerfWarn.CoarseSampleTime is to define the duration (in seconds) for sampling the percentage of frames that fall below a specified minimum FPS threshold in Unreal Engine’s performance monitoring system. This setting is used for coarse-grained performance analysis.

This setting variable is primarily used in the Unreal Editor’s performance monitoring subsystem, specifically within the UnrealEd module. The PerformanceMonitor.cpp file contains the main implementation that utilizes this variable.

The value of this variable is set as a console variable with a default value of 600 seconds (10 minutes). It can be modified at runtime through the console or configuration files.

PerfWarn.CoarseSampleTime interacts with several other performance-related variables, including:

Developers should be aware that changing this value affects the sensitivity and responsiveness of the performance monitoring system. A longer sample time provides a more stable, long-term view of performance but may be less responsive to short-term issues.

Best practices when using this variable include:

  1. Adjust the value based on the specific needs of your project. Longer times are better for catching consistent performance issues, while shorter times can help identify intermittent problems.
  2. Use in conjunction with the fine-grained sampling for a comprehensive performance analysis.
  3. Consider the impact on memory usage, as longer sample times require more data to be stored.
  4. Be cautious when modifying this value during runtime, as it will trigger a recalculation of the moving average samplers.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/PerformanceMonitor.cpp:113

Scope: file

Source code excerpt:

	TEXT("PerfWarn.FineSampleTime"), 30, TEXT("How many seconds we sample the percentage for the fine-grained minimum FPS."), ECVF_Default);
static TAutoConsoleVariable<int32> CVarCoarseSampleTime(
	TEXT("PerfWarn.CoarseSampleTime"), 600, TEXT("How many seconds we sample the percentage for the coarse-grained minimum FPS."), ECVF_Default);
static TAutoConsoleVariable<int32> CVarFineMinFPS(
	TEXT("PerfWarn.FineMinFPS"), 10, TEXT("The FPS threshold below which we warn about for fine-grained sampling."), ECVF_Default);
static TAutoConsoleVariable<int32> CVarCoarseMinFPS(
	TEXT("PerfWarn.CoarseMinFPS"), 20, TEXT("The FPS threshold below which we warn about for coarse-grained sampling."), ECVF_Default);
static TAutoConsoleVariable<int32> CVarFinePercentThreshold(
	TEXT("PerfWarn.FinePercentThreshold"), 80, TEXT("The percentage of samples that fall below min FPS above which we warn for."), ECVF_Default);

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/PerformanceMonitor.cpp:131

Scope (from outer to inner):

file
function     FPerformanceMonitor::FPerformanceMonitor
lambda-function

Source code excerpt:

	CVarDelegate = FConsoleCommandDelegate::CreateLambda([this]{
		static const auto CVarFine = IConsoleManager::Get().FindConsoleVariable(TEXT("PerfWarn.FineSampleTime"));
		static const auto CVarCoarse = IConsoleManager::Get().FindConsoleVariable(TEXT("PerfWarn.CoarseSampleTime"));

		static int32 LastTickFine = -1, LastTickCoarse = -1;

		if (CVarFine->GetInt() != LastTickFine || CVarCoarse->GetInt() != LastTickCoarse)
		{
			LastTickFine = CVarFine->GetInt();
			LastTickCoarse = CVarCoarse->GetInt();
			
			UpdateMovingAverageSamplers();
		}
	});

	CVarDelegateHandle = IConsoleManager::Get().RegisterConsoleVariableSink_Handle(CVarDelegate);
}

FPerformanceMonitor::~FPerformanceMonitor()
{
	IConsoleManager::Get().UnregisterConsoleVariableSink_Handle(CVarDelegateHandle);
}

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/PerformanceMonitor.cpp:323

Scope (from outer to inner):

file
function     void FPerformanceMonitor::Tick

Source code excerpt:

		if (PercentUnderTarget >= CVarPercentThreshold->GetFloat())
		{
			static IConsoleVariable* CoarseSampleTimeCVar = IConsoleManager::Get().FindConsoleVariable(TEXT("PerfWarn.CoarseSampleTime"));

			Arguments.Add(TEXT("Framerate"), CVarMinFPS->GetInt());
			Arguments.Add(TEXT("Percentage"), FMath::FloorToFloat(PercentUnderTarget));
			SampleTime = CoarseSampleTimeCVar->GetInt();

			bLowFramerate = true;

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/PerformanceMonitor.cpp:430

Scope (from outer to inner):

file
function     void FPerformanceMonitor::UpdateMovingAverageSamplers

Source code excerpt:

	FineMovingAverage = FMovingAverage(NumberOfSamples, SampleTime / NumberOfSamples);

	SampleTime = Console.FindConsoleVariable(TEXT("PerfWarn.CoarseSampleTime"))->GetFloat();
	CoarseMovingAverage = FMovingAverage(NumberOfSamples, SampleTime / NumberOfSamples);
}

void FPerformanceMonitor::ShowScalabilityDialog()
{
	Reset();