CauseHitches

CauseHitches

#Overview

name: CauseHitches

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 CauseHitches is to deliberately introduce performance hitches in the game for testing and debugging purposes. It is primarily used in the engine’s performance profiling and optimization systems.

This setting variable is part of Unreal Engine’s core engine module, specifically within the performance monitoring and debugging subsystem. It’s referenced in the UnrealEngine.cpp file, which is a central part of the engine’s runtime.

The value of CauseHitches is set through a console variable (cvar) using TAutoConsoleVariable. It’s initialized with a default value of 0, which means hitches are not caused by default.

CauseHitches interacts closely with another variable, CVarCauseHitchesMS. While CauseHitches determines whether hitches should be introduced, CVarCauseHitchesMS controls the duration of these hitches in milliseconds.

Developers must be aware that enabling this variable will intentionally degrade game performance. It should only be used for testing and debugging purposes, never in a production build or release version of a game.

Best practices when using this variable include:

  1. Only enable it during performance testing or when trying to reproduce performance issues.
  2. Always disable it before any performance benchmarking or when preparing builds for players.
  3. Use in conjunction with profiling tools to better understand the impact of hitches on game performance.

Regarding the associated variable CVarCauseHitchesMS:

The purpose of CVarCauseHitchesMS is to control the duration of the hitches introduced by CauseHitches. It allows developers to adjust the severity of the artificial performance degradation.

This variable is also part of the engine’s performance debugging system and is closely tied to CauseHitches.

The value of CVarCauseHitchesMS is set through a console variable, with a default value of 200 (milliseconds).

It interacts directly with CauseHitches. When CauseHitches is enabled, CVarCauseHitchesMS determines how long each hitch will last.

Developers should be cautious when adjusting this value. Setting it too high could cause the game to become unresponsive or crash.

Best practices for CVarCauseHitchesMS include:

  1. Start with smaller values and gradually increase if needed.
  2. Monitor the game’s stability when using larger values.
  3. Always reset to the default value or disable CauseHitches entirely when not actively debugging performance issues.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/UnrealEngine.cpp:11191

Scope: file

Source code excerpt:

// CauseHitches cvar
static TAutoConsoleVariable<int32> CVarCauseHitches(
	TEXT("CauseHitches"),0,
	TEXT("Causes a 200ms hitch every second. Size of the hitch is controlled by CauseHitchesHitchMS"));

static TAutoConsoleVariable<int32> CVarCauseHitchesMS(
	TEXT("CauseHitchesHitchMS"), 200,
	TEXT("Controls the size of the hitch caused by CauseHitches in ms."));

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/UnrealEngine.cpp:11189

Scope: file

Source code excerpt:

	TEXT("t.MaxFPS"),0.f,
	TEXT("Caps FPS to the given value.  Set to <= 0 to be uncapped."));
// CauseHitches cvar
static TAutoConsoleVariable<int32> CVarCauseHitches(
	TEXT("CauseHitches"),0,
	TEXT("Causes a 200ms hitch every second. Size of the hitch is controlled by CauseHitchesHitchMS"));

static TAutoConsoleVariable<int32> CVarCauseHitchesMS(
	TEXT("CauseHitchesHitchMS"), 200,

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/UnrealEngine.cpp:11190

Scope: file

Source code excerpt:

	TEXT("Caps FPS to the given value.  Set to <= 0 to be uncapped."));
// CauseHitches cvar
static TAutoConsoleVariable<int32> CVarCauseHitches(
	TEXT("CauseHitches"),0,
	TEXT("Causes a 200ms hitch every second. Size of the hitch is controlled by CauseHitchesHitchMS"));

static TAutoConsoleVariable<int32> CVarCauseHitchesMS(
	TEXT("CauseHitchesHitchMS"), 200,
	TEXT("Controls the size of the hitch caused by CauseHitches in ms."));

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/UnrealEngine.cpp:11263

Scope (from outer to inner):

file
function     float UEngine::GetMaxTickRate

Source code excerpt:

	}

	if (CVarCauseHitches.GetValueOnAnyThread())
	{
		static float RunningHitchTimer = 0.f;
		RunningHitchTimer += DeltaTime;
		float SleepTime = float(CVarCauseHitchesMS.GetValueOnAnyThread()) / 1000.0f;
		if (RunningHitchTimer > 1.f + SleepTime)
		{