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:
- It has a default value of 200 in the class declaration.
- It’s initialized to 0 in the UEnvQueryManager constructor.
- It can be configured through the engine’s configuration system, as indicated by the UPROPERTY(config) attribute.
- It’s set in the Configure function of UEnvQueryManager, likely from loaded configuration data.
This variable interacts with other variables such as:
- QueryCountWarningInterval: Determines how often the warning can be triggered.
- LastQueryCountWarningThresholdTime: Keeps track of when the last warning was issued.
- RunningQueries: The actual count of running queries is compared against this threshold.
Developers should be aware that:
- This is a diagnostic tool and doesn’t affect the actual functionality of EQS.
- Setting it too low might result in frequent warnings, while setting it too high might cause performance issues to go unnoticed.
- 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:
- Set it to a value that represents an unusual but not impossible number of simultaneous queries for your game.
- Use it in conjunction with QueryCountWarningInterval to avoid spam in logs.
- Monitor these warnings in development and testing to catch potential performance issues or logic errors in AI behavior.
- Adjust the threshold based on your game’s specific needs and the capabilities of your target hardware.
- 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]
- INI Section:
/Script/AIModule.EnvQueryManager
- Raw value:
0
- Is Array:
False
#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);
}