Unreal optimization

Finding the performance bottleneck (CPU vs GPU)

To properly test performance:

  • disable vsync (r.vsync 0)
  • and frame limiter (t.MaxFPS 0)
    • in UE 5.5 there is a bug and setting t.MaxFPS to 0 caps the FPS at 60. To overcome it, set t.MaxFPS to higher value, like 1000
  • disable smooth framerate (Project > Engine > General Settings, disabled by default)

Stat command

To turn on unit stat, click the three lines (top left corner three lines -> show stats).
or type in console: stat unit
When looking at the unit stat, the frame is total time of frame. But look at the next ones. The biggest number will hint that this is the bottleneck. In case of this screenshot, the bottlenect might be the game thread: CPU.

To change the colors of the numbers, change: “t.UnacceptableFrameTimeThreshold <milliseconds>”

Stat unitgraph

three lines in the top left corner of the viewport -> stat -> engine -> unitgraph
command stat unitgraph
To change the budget, use console command: “t.TargetFrameTimeThreshold <milliseconds>”

Here’s how to enable it:

command: “stat game” shows game related stats
stat scenerendering
stat UObjects

Unreal insights

For finding bottlenecks, look for CPU wait for tasks and in GPU gaps. Those will tell you how much this specific hardware is waiting.

It’s not clearly visible here, but the game thread calculates a frame and in the next frame the rendering thread is rendering. So on the screen you see a frame that is already one frame old.

Useful things to do when profiling:

  • test GPU load – change screen resolution (r.screenpercentage 10)
  • test CPU load – pause the game (pause)
  • add more information to the profiling session: console command: “stat namedevents”
a console command “trace.screenshot <name>” can be used to create a screenshot bookmark in insights

Tools -> Audit -> Statistics

The statitics tool shows details of a scene. In this case, all 60 instances of SM_Dining_Tableware were selected

ProfileGPU

This is a console command that you type during the game and scene you want profiled.

When game is opened, open console and type command: profilegpu . This will freeze the game for several seconds and then open GPU visualizer window and print logs to console.

There is a benchmark launch arguments to run a benchmark level right from windows

https://dev.epicgames.com/documentation/en-us/unreal-engine/unreal-engine-command-line-arguments-reference

View modes

Wireframe (shortcut F1)

Pink meshes are movable. Green enable physics

Shader complexity

Player collision

AB test

this command tests between two console command settings. Example abtest r.screenpercentage 10 100 will test screen percentage 10% and 100% and provide rudimentary results

LogConsoleResponse: Display: 13.8509ms ( 494 samples) A = 'r.screenpercentage 10'
LogConsoleResponse: Display: 18.4659ms ( 506 samples) B = 'r.screenpercentage 100'
LogConsoleResponse: Display: A is 4.6150ms faster than B; 0% chance this is noise.

Workflow

Console variables editor

It is a plugin, so it might need to be installed.
Console variables editor can listen to all variable changes and show them. In this situation I’ve changed scalability from medium to high and the variables window populated with this info.

Improving performance

Significance Manager is a tool to work on level of detail of actors.

To turn on this stat: three dots in the top left corner -> Stat -> Advanced -> SignificanceManager
In this screen we the significance manager stats, it’s update, sort, register times

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *