au.streamcaching.KeepCacheMissBufferOnFlush

au.streamcaching.KeepCacheMissBufferOnFlush

#Overview

name: au.streamcaching.KeepCacheMissBufferOnFlush

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 au.streamcaching.KeepCacheMissBufferOnFlush is to control the behavior of cache miss logging in the audio streaming system of Unreal Engine 5. Specifically, it determines whether to maintain a buffer of recorded cache misses after calling the AudioMemReport function.

This setting variable is primarily used in the audio streaming cache subsystem of Unreal Engine 5. It is referenced in the Engine module, specifically in the AudioStreamingCache.cpp file.

The value of this variable is set through the Unreal Engine console variable system. It is initialized with a default value of 1 and can be changed at runtime using console commands.

The associated variable KeepCacheMissBufferOnFlushCVar directly interacts with au.streamcaching.KeepCacheMissBufferOnFlush. They share the same value, with KeepCacheMissBufferOnFlushCVar being the actual integer variable used in the code.

Developers must be aware that this variable affects the behavior of the AudioMemReport function. When set to 1 (default), it maintains a record of all cache misses throughout the entire session. When set to 0, it only shows cache misses since the previous call to AudioMemReport.

Best practices when using this variable include:

  1. Leave it at the default value (1) during development to get a comprehensive view of all cache misses.
  2. Set it to 0 when you want to focus on recent cache misses, which can be useful for isolating issues introduced by recent changes.
  3. Use it in conjunction with the AudioMemReport function to diagnose audio streaming performance issues.

Regarding the associated variable KeepCacheMissBufferOnFlushCVar:

The purpose of KeepCacheMissBufferOnFlushCVar is to serve as the actual integer variable that stores the value of the au.streamcaching.KeepCacheMissBufferOnFlush console variable.

It is used directly in the audio streaming cache system, specifically in the FAudioChunkCache::FlushCacheMissLog() function.

The value of this variable is set by the console variable system when au.streamcaching.KeepCacheMissBufferOnFlush is modified.

This variable directly controls the behavior of the cache miss logging system. It determines whether to maintain the full history of cache misses or only the most recent ones.

Developers should be aware that this variable is used in conditional statements to control the flow of the cache miss logging process.

Best practices for using this variable include:

  1. Avoid modifying it directly in code; instead, use the console variable system to change its value.
  2. Consider the performance implications of keeping a large history of cache misses when deciding whether to enable or disable this feature.
  3. Use it in conjunction with profiling tools to optimize audio streaming performance.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AudioStreamingCache.cpp:26

Scope: file

Source code excerpt:

static int32 KeepCacheMissBufferOnFlushCVar = 1;
FAutoConsoleVariableRef CVarKeepCacheMissBufferOnFlush(
	TEXT("au.streamcaching.KeepCacheMissBufferOnFlush"),
	KeepCacheMissBufferOnFlushCVar,
	TEXT("If set to 1, this will maintain the buffer of recorded cache misses after calling AudioMemReport. Otherwise, calling audiomemreport will flush all previous recorded cache misses.\n")
	TEXT("1: All cache misses from the whole session will show up in audiomemreport. 0: Only cache misses since the previous call to audiomemreport will show up in the current audiomemreport."),
	ECVF_Default);

static int32 ForceBlockForLoadCVar = 0;

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AudioStreamingCache.cpp:24

Scope: file

Source code excerpt:

	ECVF_Default);

static int32 KeepCacheMissBufferOnFlushCVar = 1;
FAutoConsoleVariableRef CVarKeepCacheMissBufferOnFlush(
	TEXT("au.streamcaching.KeepCacheMissBufferOnFlush"),
	KeepCacheMissBufferOnFlushCVar,
	TEXT("If set to 1, this will maintain the buffer of recorded cache misses after calling AudioMemReport. Otherwise, calling audiomemreport will flush all previous recorded cache misses.\n")
	TEXT("1: All cache misses from the whole session will show up in audiomemreport. 0: Only cache misses since the previous call to audiomemreport will show up in the current audiomemreport."),
	ECVF_Default);

static int32 ForceBlockForLoadCVar = 0;
FAutoConsoleVariableRef CVarForceBlockForLoad(

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AudioStreamingCache.cpp:1331

Scope (from outer to inner):

file
function     FString FAudioChunkCache::FlushCacheMissLog

Source code excerpt:

		MissCount++;

		if (KeepCacheMissBufferOnFlushCVar)
		{
			BackupQueue.Enqueue(CacheMissInfo);
		}
	}

	// Sort our cache miss count map:

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/AudioStreamingCache.cpp:1367

Scope (from outer to inner):

file
function     FString FAudioChunkCache::FlushCacheMissLog

Source code excerpt:

	// If we are keeping the full cache miss buffer around, re-enqueue every cache miss we dequeued.
	// Note: This could be done more gracefully if TQueue had a move constructor.
	if (KeepCacheMissBufferOnFlushCVar)
	{
		while (BackupQueue.Dequeue(CacheMissInfo))
		{
			CacheMissQueue.Enqueue(CacheMissInfo);
		}
	}