Course contentsShow
← Unreal Engine Game Development
Lesson 469 of 8806. AI, Navigation, and Decision MakingFree lesson

Profiling AI Performance with Unreal Insights

You will use Unreal Insights to identify CPU bottlenecks caused by expensive AI decision-making cycles and high-frequency EQS queries in your project.

In this lesson, you will learn how to leverage Unreal Insights to pinpoint specific CPU spikes caused by heavy AI decision-making cycles and expensive Environment Query System (EQS) operations.

When your AI agents scale, Behavior Trees and EQS queries often become the primary suspects for frame rate drops. While the Visual Logger helps us see what an AI is thinking, Unreal Insights tells us how much that thinking costs the CPU.

Capturing the Data

To start profiling, run your project with the command line argument -trace=cpu,ai. Once you’ve reproduced the performance hitch in-game, close the application and open the resulting .utrace file in the Unreal Insights browser.

Identifying Bottlenecks

Once inside the Timing Insights window, navigate to the CPU View. Look for deep stacks under the GameThread. You are looking for two specific culprits:

  1. Behavior Tree Ticks: If you see UBehaviorTreeComponent::TickComponent taking up a large percentage of the frame, your AI logic is likely too complex or running too frequently.
  2. EQS Queries: Search for UEQSRunner. If you see wide bars here, your agents are likely running high-frequency spatial queries that perform costly line-of-sight checks or distance calculations across large portions of the level.

Optimizing via Insights

If you identify that a specific Task or EQS Query is the bottleneck, you can optimize the logic by implementing "State Caching" (as we learned in lesson 8). For example, if your profiling reveals an expensive EQS_FindCover query running every frame, you should throttle its execution:

// Instead of running every tick, check if the query is already running
if (!EQSQueryInstance.IsValid()) {
    // Only trigger query if the AI state has changed
    RunEQSQuery(QueryTemplate);
}

By observing the exact duration of these calls in the timeline, you can verify if your optimizations—such as spreading EQS queries across multiple frames or caching Blackboard values—have successfully reduced the CPU "ms" cost.

Key Takeaway: Use Unreal Insights to move from guessing about performance to measuring the exact millisecond cost of your AI tasks and EQS queries.