Unreal Insights Overview

Overview of Unreal Insights application profiling tool

Windows
MacOS
Linux

Unreal Insights helps developers identify bottlenecks, which is useful when optimizing for performance. At a high level, Unreal Insights is a standalone profiling system that integrates with Unreal Engine to collect, analyze, and visualize data emitted by the engine. In addition to providing robust coverage of the Engine's existing systems, Unreal Insights makes it easy to add your profiling data. Finally, the system features the capability to record data remotely, minimizing the application's impact on your project's execution.

Setup

The Unreal Insights tool ships with Unreal Engine, located in the Engine/Binaries/Win64 directory. For users who download the UE4 source code and compile it locally, you can compile it either by building the entire UE4 solution in Development or Shipping mode, or by building the "UnrealInsights" project directly.

UnrealInsightsProjectVisualStudio.png

Once you have located or built the compiled program (UnrealInsights.exe), run it on the machine that you want to use to record your data or view your live session. To minimize the tool's impact on your application's performance, we recommend running the tool on a different machine than the project you need to monitor. It's still possible to run both the project and the tool on a single computer, though keep in mind that the tool must be running first because the project will attempt to connect to the tool as soon as it starts up.

If the tool is running remotely, provide its IP to the project by launching the project with the following command-line option, replacing "X" with the IP: -tracehost=X

  • You only need the "-tracehost=X" argument when running on remote devices, Mac, and Linux.

  • When launching on Windows (and if it's discoverable), the runtime will automatically connect to Unreal Insights.

While starting the application, it displays Trace Sessions (1), a Trace Store Directory (2) control, and a New Connection (3) menu.

UnrealInsightsBrowser.png

After opening a trace session for analysis, Unreal Insights displays three window tabs. Two of the window tabs, including the Timing Insights window and the Asset Loading Insights window, browse and visualize performance data, and will appear after a session is ready for viewing. When first opening the tool for analysis, it defaults by opening the Unreal Insights window, which helps to manage different sessions by connecting, disconnecting, and selecting live or pre-recorded sessions for viewing.

Unreal Insights Window

When the tool starts up, the Unreal Insights window opens first. In the top section of the window, labeled Trace Sessions, you will see a list of all pre-recorded sessions that you can load for analysis. These correspond to the .utrace files in your Local Session Directory. You can double-click any of these trace sessions (or select a trace session and click Open), or you can search for .utrace files elsewhere with the Open dropdown arrow.

If a live UE4 session connects to the tool, it will also appear in the list. Live sessions have the word "LIVE" in the status column, and update in real time while you analyze them, but are otherwise identical to pre-precorded sessions. The tool can connect multiple sessions at the same time, and it will automatically record data for all of them as the data streams in. You can analyze these sessions in real-time by loading them from the list (just as you would with pre-recorded sessions).

UnrealInsightsLiveSession.png

Live session available for real-time analysis in the Unreal Insights window

The Trace Recorder section includes a Stop button to stop trace recording without closing the tool. This is useful for stopping the flow of new data into a live session after you have collected the data you need, but before the session has ended, which can make it easier to read. Pressing this button also disconnects the tool from running sessions, and prevents new sessions from connecting. While recording is stopped, Start appears in place of Stop. Restarting recording will enable new remote Unreal Engine sessions to connect, but will not connect to any sessions that started while trace recording was stopped, and will not reconnect to sessions that were dropped by Stop.

UnrealInsightsStopped.png

The bottom section (New Connection) features an experimental Connect button and a text-entry field for users to enter the session IP that is already in progress. This is intended primarily for use with game consoles, but is still a work in progress and may not be reliable. Look for futher iteration on this feature in future releases. At present, starting the Unreal Insights Tool before launching the project and using the -tracehost command-line option for your project is the only recommended procedure.

Timing Insights Window

The Timing Insights window is where you'll see per-frame performance data for the CPU and GPU. There are several panels where you can look at different visualizations of the time your project spends on various tasks. You can select blocks of time to view in aggregate, sort or categorize data, and review log output. You can show or hide these panels with the five buttons along the top row, labeled Frames, Timing, Timers, Stats, and Log. These buttons show or hide the Frames panel, Timing panel, Timers tab, Stats Counters tab, and Log panel.

To learn how to efficiently navigate Timing Insights, read the 언리얼 인사이트 레퍼런스

TimingInsightsPanels.png

The Timing Insights window features the Frames panel (1), the Timing panel (2), the Log panel (3), the Timers and Counters tabs (4), and the Callers and Callees panels (5).

A key feature of the Timing Insights window is the ability to select a single frame or period of time and show performance information collected during that time by highlighting and zooming the Timing panel, and aggregating data in the Timers tab and Stats Counters tab. To do this, you can click on a single frame in the Frames panel, or click and drag a section of the scrub bar at the top of the Timing panel, known as the Time Ruler.

The Timers and Counters panels feature a !0 toggle to filter out timers and counters with instance counts (aggregated statistics) that add up to zero.

Frames Panel

The Frames panel shows the total time taken by each frame, using a bar graph format. This is good for identifying general trends, such as the framerate lowering when a certain level is loaded or an unoptimized scene is visible, or discovering the reason for an individual frame being slow, such as spawning a large number of Actors all at once. Since taller bars represent longer frames, it's easy to pick out the exact moment when these events happen, and examine the data to see which operations are responsible. Hovering the cursor over a bar causes that frame's index and running time to appear. If you then left-click the bar, you can isolate data for that frame in the Timing panel, Timers tab, and Stats Counters tab.

FramesPanel.png

A selected frame within the Frames panel. The white bracket marker shows the set of frames visible within the Timing panel.

Timing Panel

The bulk of your time in Unreal Insights will be spent on the Timing panel. This panel shows a visual representation of each instance of every timer event that has run during a session. Unlike the Frames panel, which provides an overview of whole frames, the Timing panel shows individual trace events and provides time measurements with sub-microsecond precision. These events stack vertically to indicate scope, and use separate tracks to show activity on different threads. Within the track display, events are broken out by thread, divided vertically to show scope, and positioned horizontally based on their start and end times.

TimingPanel.png

(1) The tooltip that appears when hovering over a timer event within the Timing panel. (2) A stack of nested events on the same thread.

You can turn groups of related threads on or off in the Tracks dropdown in the upper-left corner of the panel. Hovering the mouse cursor over a block in any track reveals information about that timer event, and clicking on it locates and selects the event in the Timers tab.

TracksDropdown.png

The Timing panel features a dropdown menu to hide or show groups of tracks based on what threads they contain.

When working with the Timing panel, you may wish to see aggregate data for a specific time range. You can select the period of time that you want to examine by clicking and dragging across the Time Ruler, double-clicking a timer event in the Timing tab, or clicking a frame in the Frames panel. When you do this, the selected time range appears as a blue overlay with its total length shown at the top, and the Timer tab and Stats Counter tab show only the data that falls within that time range. You can then press F to zoom and pan directly to the selected time range.

Timers Tab and Stats Counters Tab

The Timers tab lists all timer events that have run within the time range designated in the Timing panel, while the Stats Counters tab lists all stats that were incremented during the same period. In addition to aggregating data based on time range, this list can be sorted in ascending or descending order by the values in any active column. To change sort order, or to activate or deactivate columns, right-click anywhere in the list. The following columns are available:

For the Timers tab:

  • Meta Group Name

  • Type

  • Instance Count

  • Total Inclusive Time

  • Max Inclusive Time (ms)

  • Average Inclusive Time (ms)

  • Median Inclusive Time (ms)

  • Min Inclusive Time (ms)

  • Total Exclusive Time

  • Max Exclusive Time (ms)

  • Average Exclusive Time (ms)

  • Median Exclusive Time (ms)

  • Min Exclusive Time (ms)

For the Stats Counters tab:

  • Meta Group Name

  • Type

  • Count

  • Sum

  • Maximum

  • Upper Quartile (not yet implemented in 4.23)

  • Average

  • Median

  • Lower Quartile (not yet implemented in 4.23)

  • Minimum

Both lists also feature the Group By dropdown list box, which has the ability to separate the list into groups by name or type, or combine them all into a single, flat group. You can then expand or collapse groups to view just the data you need to see.

TimersTabByName.png

The Timers tab is broken into groups based on name.

The Stats Counters tab will be empty by default because it is considered an experimental feature (and deactivated by default).

Log Panel

The Log panel displays all logs (generated by UE_LOG calls) from the UE4 session. The logs can be filtered by verbosity and category, just as in the Output Log window in the Editor. It also features a search box that filters out all log messages that don't match the text you enter. In addition to filtering, clicking on any row will pan the Timing panel to the time when that row's text was logged.

LogPanel.png

Selecting a time period in the Timing panel highlights all log entries that fall within that time (in blue). Conversely, if you select multiple log entries, by clicking one entry and then shift-clicking another, the Timing panel highlights the time range between those entries.

Asset Loading Insights Window

To analyze Asset loading performance, the Unreal Insights Tool features the Asset Loading Insights window. This window contains a specialized version of the Timing panel from the Timing Insights view that has been configured to focus on events related to loading Assets.

AssetLoadingInsights.png

The Asset Loading Insights window focuses on performance related to loading Assets. The session shown here was recorded with the -loadtimetrace command-line option.

Customizing Your Project's Output

By making some minor changes to engine, plugin, or project source code, you can activate or deactivate certain Unreal Insights features. You can also add custom logging.

Activating or Deactivating Logging

If you want to exercise control over which areas send logging data, or if you simply want to deactivate the entire system, you can do this by editing the engine's source code and changing the values of certain macros. These macros are spread across the engine, generally in header files for the relevant features or modules. They use the value "1" for areas that have logging turned on, and "0" where it's off, but are always defined within a conditional structure that first determines whether or not the macro is appropriate within the context of the build. LOGTRACE_ENABLED is the macro that controls log message tracing, residing in Engine/Source/Runtime/Core/Public/Logging/LogTrace.h within the following structure:

#if !IS_PROGRAM && !UE_BUILD_SHIPPING && (PLATFORM_WINDOWS || PLATFORM_PS4 || PLATFORM_XBOXONE)
#define LOGTRACE_ENABLED 1
#else
#define LOGTRACE_ENABLED 0
#endif

By default, LOGTRACE_ENABLED is defined as "1" in builds where it is appropriate to send log data to the Unreal Insights system. To deactivate it, the second line in the code (above) would be changed so that LOGTRACE_ENABLED is defined as "0" rather than "1".

To learn about the currently available macros and command-line options, read the 언리얼 인사이트 레퍼런스 .

Adding Custom Logging

To add logging to your own engine features, plugins, or projects, invoke the TRACE_CPUPROFILER_EVENT_SCOPE macro at the scope that you wish to profile. This macro takes a single text argument to identify the trace group that will own the profiling data it generates. You can use any name you like, but common examples might look like TRACE_CPUPROFILER_EVENT_SCOPE(TEXT("MyClass::Function")) or TRACE_CPUPROFILER_EVENT_SCOPE(TEXT("ReticulatingSplines")). Remember that the UE_LOG macro shows up in Unreal Insights, so putting logs near areas of the code that you want to investigate could help you to find the information you need faster when analyzing data.

Platform Details

With Unreal Insights, it is possible to collect trace data on a few platforms, such as Android and PC.

Android

Using Android Debug Bridge (adb), Android tools can redirect TCP traffic over a USB cable. To connect a runtime application on an Android device, first instruct adb to pass through TCP connections made on the device over USB:

adb.exe reverse tcp:1980 tcp:1980

Unreal Insights listens on TCP port 1980.

When running on the device, it should connect to localhost, such that the operating system will route traffic across the USB cable.

-tracehost=127.0.0.1

Switch

Switch has two methods of communicating over the wire; either on a normal network over Wi-Fi/over a wired LAN adapter, or on HTCS, which is the Ethernet port available on SDEV kits.

To trace over a normal network, use -tracehost=IPADDR.

This only supports an IP address, otherwise, Trace will assume it is an HTCS peer.

Trace over HTCS with -tracehost=PEERNAME, following these recommended steps:

  1. Install Nmap.

  2. Start Nintendo Target Manager.

  3. Run ncat.exe 127.0.0.1 8003.

    This connects to Target Manager, printing its XML response.

  4. Paste the following text into the Ncat console window (the following must include, or be followed by, the CRLF bytecode): <RegisterPortMapCommand><PortMapItem><HtcsPeerName></HtcsPeerName><HtcsPortName>UETrace_1980</HtcsPortName><IPAddress>127.0.0.1</IPAddress><TcpPortNumber>1980</TcpPortNumber></PortMapItem></RegisterPortMapCommand>

  5. In addition to your development PC's hostname, you should find UETrace_1980 listed in Target Manager's HTCS Entries.

  6. Run on Switch with the -tracehost=[PeerName] where PeerName matches the HTCS Entries row.

Files

Trace can output to a file using the -tracefile=PATH command line argument. The value of PATH is specific to the platform being traced, including PC and Android.

PC

-tracefile=d:/foo/bar.utrace

Android

-tracefile=/sdcard/UE4Game/foobar.utrace

While any user-specified path should work, the /sdcard/ path may vary depending on the Android OS version and device manufacturer.

Switch

-tracefile=host:foobar.utrace

This traces to the host PC into the working directory on the given host when launching the binary via Target Manager.

PS4

-tracefile=/data/foobar.utrace

If you mapped a drive in Explorer, you can find the trace there. Although, other mount points may be used, including /host/d:/foo/bar.utrace or /app0/..., which may vary, depending on how you launch PS4.

Select Skin
Light
Dark

Welcome to the new Unreal Engine 4 Documentation site!

We're working on lots of new features including a feedback system so you can tell us how we are doing. It's not quite ready for use in the wild yet, so head over to the Documentation Feedback forum to tell us about this page or call out any issues you are encountering in the meantime.

We'll be sure to let you know when the new system is up and running.

Post Feedback