au.RecycleThreads

au.RecycleThreads

#Overview

name: au.RecycleThreads

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 au.RecycleThreads is to manage thread recycling in the audio mixer system of Unreal Engine 5. It controls whether threads should be reused instead of being created and destroyed repeatedly.

This setting variable is primarily used in the Audio Mixer Core subsystem of Unreal Engine 5, as evidenced by its location in the AudioMixer.cpp file within the AudioMixerCore module.

The value of this variable is set through a console variable (CVar) system. It is initialized with a default value of 1 (enabled) and can be changed at runtime using console commands.

The au.RecycleThreads variable interacts directly with the bRecycleThreadsCVar variable. They share the same value, with bRecycleThreadsCVar being the actual variable used in the code logic.

Developers should be aware that this variable affects the performance and resource management of the audio system. When enabled (set to 1), it keeps threads alive for reuse, which can improve performance by reducing the overhead of thread creation and destruction. However, it may also lead to increased memory usage if many threads are kept alive.

Best practices when using this variable include:

  1. Leave it enabled (default value of 1) unless there’s a specific reason to disable it.
  2. Monitor performance and memory usage when modifying this setting.
  3. Consider disabling it (setting to 0) if you notice memory issues related to thread management in the audio system.

Regarding the associated variable bRecycleThreadsCVar:

The purpose of bRecycleThreadsCVar is to serve as the actual integer storage for the au.RecycleThreads setting. It is used directly in the code logic to determine whether thread recycling should occur.

This variable is used in the IAudioMixer::ShouldRecycleThreads() function, which likely influences thread management decisions throughout the Audio Mixer Core subsystem.

The value of bRecycleThreadsCVar is set through the CVar system, mirroring the value of au.RecycleThreads.

As mentioned earlier, bRecycleThreadsCVar interacts directly with au.RecycleThreads, sharing the same value.

Developers should be aware that modifying bRecycleThreadsCVar directly in code is not recommended. Instead, they should use the CVar system to modify au.RecycleThreads, which will automatically update bRecycleThreadsCVar.

Best practices for bRecycleThreadsCVar include:

  1. Avoid modifying it directly in code; use the CVar system instead.
  2. When reading its value in code, consider using the IAudioMixer::ShouldRecycleThreads() function for consistency and potential future compatibility.
  3. Be aware of its impact on audio thread management when debugging or profiling audio-related performance issues.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/AudioMixerCore/Private/AudioMixer.cpp:98

Scope: file

Source code excerpt:

static int32 bRecycleThreadsCVar = 1;
FAutoConsoleVariableRef CVarRecycleThreads(
	TEXT("au.RecycleThreads"),
	bRecycleThreadsCVar,
	TEXT("Keeps threads to reuse instead of create/destroying them")
	TEXT("0 off, 1 on"),
	ECVF_Default);

static int32 OverrunTimeoutCVar = 5000;

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/AudioMixerCore/Private/AudioMixer.cpp:96

Scope: file

Source code excerpt:

	ECVF_Default);
	
static int32 bRecycleThreadsCVar = 1;
FAutoConsoleVariableRef CVarRecycleThreads(
	TEXT("au.RecycleThreads"),
	bRecycleThreadsCVar,
	TEXT("Keeps threads to reuse instead of create/destroying them")
	TEXT("0 off, 1 on"),
	ECVF_Default);

static int32 OverrunTimeoutCVar = 5000;
FAutoConsoleVariableRef CVarOverrunTimeout(

#Loc: <Workspace>/Engine/Source/Runtime/AudioMixerCore/Private/AudioMixer.cpp:915

Scope (from outer to inner):

file
namespace    Audio
function     bool IAudioMixer::ShouldRecycleThreads

Source code excerpt:

	bool IAudioMixer::ShouldRecycleThreads()
	{
		return bRecycleThreadsCVar != 0;
	}


}

FAudioPlatformSettings FAudioPlatformSettings::GetPlatformSettings(const TCHAR* PlatformSettingsConfigFile)