AudioThread.EnableBatchProcessing
AudioThread.EnableBatchProcessing
#Overview
name: AudioThread.EnableBatchProcessing
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Enables batch processing audio thread commands.\n0: Not Enabled, 1: Enabled
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of AudioThread.EnableBatchProcessing is to control batch processing of audio thread commands in Unreal Engine 5. This setting variable is primarily used in the audio system of the engine.
The Unreal Engine subsystem that relies on this setting variable is the audio thread processing system, which is part of the Engine module. This can be seen from the file path where the variable is defined: Engine/Source/Runtime/Engine/Private/AudioThread.cpp.
The value of this variable is set using an FAutoConsoleVariableRef, which allows it to be modified at runtime through the console. By default, it is set to 1 (enabled).
This variable interacts with another variable named GBatchAudioAsyncBatchSize, which determines the batch size for audio processing when batch processing is enabled.
Developers must be aware that this variable affects the performance and behavior of audio processing in the engine. When enabled (set to 1), it allows for batch processing of audio commands, which can potentially improve performance by reducing the number of individual thread operations.
Best practices when using this variable include:
- Keep it enabled (default value of 1) unless there’s a specific reason to disable it.
- If experiencing audio-related performance issues, experiment with enabling/disabling this setting to see if it affects performance in your specific use case.
- When modifying this setting, also consider adjusting the GBatchAudioAsyncBatchSize variable to fine-tune the batch processing behavior.
Regarding the associated variable GCVarEnableBatchProcessing:
The purpose of GCVarEnableBatchProcessing is to serve as the internal representation of the AudioThread.EnableBatchProcessing console variable. It is used within the C++ code to check whether batch processing is enabled.
This variable is used in the Engine module, specifically in the audio thread processing system.
The value of GCVarEnableBatchProcessing is set by the FAutoConsoleVariableRef CVarEnableBatchProcessing, which links it to the AudioThread.EnableBatchProcessing console variable.
GCVarEnableBatchProcessing interacts directly with the audio thread processing logic. For example, it’s used in a conditional statement to determine whether to add work items to a batch or process them immediately.
Developers should be aware that modifying GCVarEnableBatchProcessing directly in code is not recommended. Instead, they should use the AudioThread.EnableBatchProcessing console variable to control this setting.
Best practices for GCVarEnableBatchProcessing include:
- Treat it as a read-only variable in most cases, using it for conditional checks in audio processing code.
- If needed, modify its value through the AudioThread.EnableBatchProcessing console variable rather than changing it directly in code.
- When reading this variable in performance-critical code, consider caching its value locally if it’s used multiple times in a tight loop, as reading console variables can have a small performance cost.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AudioThread.cpp:29
Scope: file
Source code excerpt:
static int32 GCVarEnableBatchProcessing = 1;
FAutoConsoleVariableRef CVarEnableBatchProcessing(
TEXT("AudioThread.EnableBatchProcessing"),
GCVarEnableBatchProcessing,
TEXT("Enables batch processing audio thread commands.\n")
TEXT("0: Not Enabled, 1: Enabled"),
ECVF_Default);
static int32 GBatchAudioAsyncBatchSize = 128;
#Associated Variable and Callsites
This variable is associated with another variable named GCVarEnableBatchProcessing
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AudioThread.cpp:27
Scope: file
Source code excerpt:
FAutoConsoleVariableRef CVarEnableAudioCommandLogging(TEXT("AudioThread.EnableAudioCommandLogging"), GCVarEnableAudioCommandLogging, TEXT("0=Disbaled, 1=Enabled"), ECVF_Default);
static int32 GCVarEnableBatchProcessing = 1;
FAutoConsoleVariableRef CVarEnableBatchProcessing(
TEXT("AudioThread.EnableBatchProcessing"),
GCVarEnableBatchProcessing,
TEXT("Enables batch processing audio thread commands.\n")
TEXT("0: Not Enabled, 1: Enabled"),
ECVF_Default);
static int32 GBatchAudioAsyncBatchSize = 128;
static FAutoConsoleVariableRef CVarBatchAudioAsyncBatchSize(
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AudioThread.cpp:209
Scope (from outer to inner):
file
function void Add
Source code excerpt:
#if !WITH_EDITOR
if (GCVarEnableBatchProcessing)
{
if (WorkItems.Num() >= GBatchAudioAsyncBatchSize) // collected enough work
{
Flush();
}
WorkItems.Add(Forward<FWork>(Work));