QueryCountWarningThreshold

QueryCountWarningThreshold

#Overview

name: QueryCountWarningThreshold

The value of this variable can be defined or overridden in .ini config files. 1 .ini config file referencing this setting variable.

It is referenced in 7 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of QueryCountWarningThreshold is to set a threshold for the number of running Environment Query System (EQS) queries, beyond which a warning will be logged. This variable is part of the AI system in Unreal Engine, specifically related to the Environment Query System.

The Unreal Engine subsystem that relies on this setting variable is the AI Module, particularly the Environment Query System (EQS) managed by the EnvQueryManager class.

The value of this variable is set in multiple places:

  1. It has a default value of 200 in the class declaration.
  2. It’s initialized to 0 in the UEnvQueryManager constructor.
  3. It can be configured through the engine’s configuration system, as indicated by the UPROPERTY(config) attribute.
  4. It’s set in the Configure function of UEnvQueryManager, likely from loaded configuration data.

This variable interacts with other variables such as:

Developers should be aware that:

  1. This is a diagnostic tool and doesn’t affect the actual functionality of EQS.
  2. Setting it too low might result in frequent warnings, while setting it too high might cause performance issues to go unnoticed.
  3. It’s only effective when greater than zero; setting it to zero or a negative value disables the warning.

Best practices when using this variable include:

  1. Set it to a value that represents an unusual but not impossible number of simultaneous queries for your game.
  2. Use it in conjunction with QueryCountWarningInterval to avoid spam in logs.
  3. Monitor these warnings in development and testing to catch potential performance issues or logic errors in AI behavior.
  4. Adjust the threshold based on your game’s specific needs and the capabilities of your target hardware.
  5. Consider different thresholds for different build configurations (development vs shipping).

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseGame.ini:214, section: [/Script/AIModule.EnvQueryManager]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/AIModule/Classes/EnvironmentQuery/EnvQueryManager.h:43

Scope: file

Source code excerpt:

	/** if greater than zero, we will warn once when the number of queries is greater than or equal to this number, and log the queries out */
	UPROPERTY(config)
	int32 QueryCountWarningThreshold = 200;

	/** how often (in seconds) we will warn about the number of queries (allows us to catch multiple occurrences in a session) */
	UPROPERTY(config)
	double QueryCountWarningInterval = 60.0f;

	/** Maximum EQS execution duration (in seconds) before a warning is reported. */

#Loc: <Workspace>/Engine/Source/Runtime/AIModule/Classes/EnvironmentQuery/EnvQueryManager.h:347

Scope (from outer to inner):

file
class        class UEnvQueryManager : public UAISubsystem, public FSelfRegisteringExec

Source code excerpt:

	/** if greater than zero, we will warn once when the number of queries is greater than or equal to this number, and log the queries out */
	UPROPERTY(config)
	int32 QueryCountWarningThreshold;

	/** how often (in seconds) we will warn about the number of queries (allows us to catch multiple occurrences in a session) */
	UPROPERTY(config)
	double QueryCountWarningInterval;

	/** Maximum EQS execution duration (in seconds) before a warning is reported. */

#Loc: <Workspace>/Engine/Source/Runtime/AIModule/Private/EnvironmentQuery/EnvQueryManager.cpp:182

Scope (from outer to inner):

file
function     UEnvQueryManager::UEnvQueryManager

Source code excerpt:

	NumRunningQueriesAbortedSinceLastUpdate = 0;

	QueryCountWarningThreshold = 0;
	QueryCountWarningInterval = 30.0;
#if !(UE_BUILD_SHIPPING)
	LastQueryCountWarningThresholdTime = -FLT_MAX;
#endif

#if USE_EQS_DEBUGGER

#Loc: <Workspace>/Engine/Source/Runtime/AIModule/Private/EnvironmentQuery/EnvQueryManager.cpp:633

Scope (from outer to inner):

file
function     void UEnvQueryManager::CheckQueryCount

Source code excerpt:

void UEnvQueryManager::CheckQueryCount() const
{
	if ((QueryCountWarningThreshold > 0) && (RunningQueries.Num() >= QueryCountWarningThreshold))
	{
		const double CurrentTime = FPlatformTime::Seconds();

		if ((LastQueryCountWarningThresholdTime < 0.0) || ((LastQueryCountWarningThresholdTime + QueryCountWarningInterval) < CurrentTime))
		{
			LogQueryInfo(true /* bDisplayThresholdWarning */);

#Loc: <Workspace>/Engine/Source/Runtime/AIModule/Private/EnvironmentQuery/EnvQueryManager.cpp:650

Scope (from outer to inner):

file
function     void UEnvQueryManager::LogQueryInfo

Source code excerpt:

	if (bDisplayThresholdWarning)
	{
		UE_VLOG_ALWAYS_UELOG(this, LogEQS, Warning, TEXT("The number of EQS queries (%d) has reached the warning threshold (%d).  Logging queries."), RunningQueries.Num(), QueryCountWarningThreshold);
	}
	else
	{
		UE_VLOG_ALWAYS_UELOG(this, LogEQS, Warning, TEXT("The number of EQS queries is (%d).  Logging queries."), RunningQueries.Num());
	}

#Loc: <Workspace>/Engine/Source/Runtime/AIModule/Private/EnvironmentQuery/EnvQueryManager.cpp:1140

Scope (from outer to inner):

file
function     void UEnvQueryManager::Configure

Source code excerpt:

	MaxAllowedTestingTime = NewConfig.MaxAllowedTestingTime;
	bTestQueriesUsingBreadth = NewConfig.bTestQueriesUsingBreadth;
	QueryCountWarningThreshold = NewConfig.QueryCountWarningThreshold;
	QueryCountWarningInterval = NewConfig.QueryCountWarningInterval;
	ExecutionTimeWarningSeconds = NewConfig.ExecutionTimeWarningSeconds;
	HandlingResultTimeWarningSeconds = NewConfig.HandlingResultTimeWarningSeconds;
	GenerationTimeWarningSeconds = NewConfig.GenerationTimeWarningSeconds;	
}

#Loc: <Workspace>/Engine/Source/Runtime/AIModule/Private/EnvironmentQuery/EnvQueryManager.cpp:1321

Scope (from outer to inner):

file
function     FString FEnvQueryManagerConfig::ToString

Source code excerpt:

FString FEnvQueryManagerConfig::ToString() const
{
	return FString::Printf(TEXT("MaxAllowedTestingTime=%f bTestQueriesUsingBreadth=%d QueryCountWarningThreshold=%d QueryCountWarningInterval=%f ExecutionTimeWarningSeconds=%f HandlingResultTimeWarningSeconds=%f GenerationTimeWarningSeconds=%f"), MaxAllowedTestingTime, bTestQueriesUsingBreadth, QueryCountWarningThreshold, QueryCountWarningInterval, ExecutionTimeWarningSeconds, HandlingResultTimeWarningSeconds, GenerationTimeWarningSeconds);
}