au.MetaSound.OperatorPoolHitRateWindowSeconds

au.MetaSound.OperatorPoolHitRateWindowSeconds

#Overview

name: au.MetaSound.OperatorPoolHitRateWindowSeconds

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.MetaSound.OperatorPoolHitRateWindowSeconds is to control the duration for which hit/miss results are considered relevant in the success rate reporting of the MetaSound operator pool. This setting variable is part of the MetaSound system, which is a plugin for audio programming in Unreal Engine.

The MetaSound subsystem, specifically the operator cache component within the MetasoundGenerator module, relies on this setting variable. It is used to manage the efficiency of the operator pool by tracking the hit rate over a specified time window.

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

This variable interacts closely with an associated variable named MetasoundPoolHitRateWindowSecondsCVar. They share the same value, with MetasoundPoolHitRateWindowSecondsCVar being the actual storage for the value, while au.MetaSound.OperatorPoolHitRateWindowSeconds is the console variable reference.

Developers must be aware that changing this variable affects the sensitivity of the hit rate calculation. A longer window will provide a more stable but less responsive measure of the cache’s effectiveness, while a shorter window will be more reactive to recent changes but potentially more volatile.

Best practices when using this variable include:

  1. Monitoring the hit rate alongside this setting to understand its impact on cache performance.
  2. Adjusting the value based on the specific needs of the audio system in the game.
  3. Being cautious about setting extremely short windows, as they might lead to overly reactive behavior.

Regarding the associated variable MetasoundPoolHitRateWindowSecondsCVar:

The purpose of MetasoundPoolHitRateWindowSecondsCVar is to store the actual value of the hit rate window duration used by the MetaSound operator cache system. It serves as the backing variable for the console variable au.MetaSound.OperatorPoolHitRateWindowSeconds.

This variable is used directly in the MetasoundGenerator module, specifically within the OperatorPoolPrivate namespace. It’s utilized in the FWindowedHitRate class to initialize and update the time-to-live (TTL) for hit rate calculations.

The value of MetasoundPoolHitRateWindowSecondsCVar is set indirectly through the au.MetaSound.OperatorPoolHitRateWindowSeconds console variable. Any changes to the console variable will be reflected in this associated variable.

MetasoundPoolHitRateWindowSecondsCVar interacts closely with the FWindowedHitRate class, influencing how long hit/miss results are considered relevant for success rate reporting.

Developers should be aware that this variable is used in performance-critical code paths related to audio processing. Changes to its value can affect the responsiveness and accuracy of the operator cache hit rate calculations.

Best practices for using MetasoundPoolHitRateWindowSecondsCVar include:

  1. Avoiding direct manipulation of this variable; instead, use the console variable system to modify its value.
  2. Considering the impact on audio performance when adjusting the hit rate window duration.
  3. Monitoring the effects of changes to this variable on the overall MetaSound system performance.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Plugins/Runtime/Metasound/Source/MetasoundGenerator/Private/MetasoundOperatorCache.cpp:40

Scope (from outer to inner):

file
namespace    Metasound
namespace    OperatorPoolPrivate

Source code excerpt:

		static float MetasoundPoolHitRateWindowSecondsCVar = 1.0f;
		FAutoConsoleVariableRef CVarMetasoundPoolHitRateWindowSeconds(
			TEXT("au.MetaSound.OperatorPoolHitRateWindowSeconds"),
			MetasoundPoolHitRateWindowSecondsCVar,
			TEXT("Control how long hit/miss results matter for the success rate reporting.\n"),
			ECVF_Default);

		double GetHitRatio()
		{

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Plugins/Runtime/Metasound/Source/MetasoundGenerator/Private/MetasoundOperatorCache.cpp:38

Scope (from outer to inner):

file
namespace    Metasound
namespace    OperatorPoolPrivate

Source code excerpt:

		static std::atomic<uint32> CacheAttemptCount = 0;

		static float MetasoundPoolHitRateWindowSecondsCVar = 1.0f;
		FAutoConsoleVariableRef CVarMetasoundPoolHitRateWindowSeconds(
			TEXT("au.MetaSound.OperatorPoolHitRateWindowSeconds"),
			MetasoundPoolHitRateWindowSecondsCVar,
			TEXT("Control how long hit/miss results matter for the success rate reporting.\n"),
			ECVF_Default);

		double GetHitRatio()
		{
			uint32 NumHits = CacheHitCount;

#Loc: <Workspace>/Engine/Plugins/Runtime/Metasound/Source/MetasoundGenerator/Private/MetasoundOperatorCache.cpp:60

Scope (from outer to inner):

file
namespace    Metasound
namespace    OperatorPoolPrivate
function     FWindowedHitRate::FWindowedHitRate

Source code excerpt:


		FWindowedHitRate::FWindowedHitRate()
		: CurrTTLSeconds(MetasoundPoolHitRateWindowSecondsCVar)
		{
		}

		void FWindowedHitRate::Update()
		{
			if (bIsFirstUpdate)

#Loc: <Workspace>/Engine/Plugins/Runtime/Metasound/Source/MetasoundGenerator/Private/MetasoundOperatorCache.cpp:72

Scope (from outer to inner):

file
namespace    Metasound
namespace    OperatorPoolPrivate
function     void FWindowedHitRate::Update

Source code excerpt:

			}

			if (CurrTTLSeconds != MetasoundPoolHitRateWindowSecondsCVar)
			{
				SetWindowLength(MetasoundPoolHitRateWindowSecondsCVar);
			}
	
			// Incorporate latest results
			// note:	there a sliver of a race condition here between the 2 values
			// 			but we should be able to afford the occasional off-by-one and
			// 			avoid mutex contention