RHI and Game Threads are massively stalling (4.4ms wait time!)

See image attached below - there is a massive delay here, and I can’t seem to figure out why. The biggest task that causes the wait is OcclusionCulling, but I feel that’s a symptom rather than a cause.

Any tips for how to find out what’s causing this? I’m not doing anything too fancy with the rendering pipeline. On UE5.5 for reference.

Hi, from the image looks like you are bound by the GPU, top row. It takes around 7ms, so both the game thread and render thread will have to wait for it to finish. From what I’ve seen so far, the game thread waits by GameThreadWaitForTask, whereas the render thread waits inside the ProcessVisiblityTasks / OcclusionCulling.

So there is no problematic delay there, the GPU is simply the bottleneck. For reducing the ambient occlusion time, in 5.4 I found this console command here: “r.AmbientOcclusionMaxQuality 0“ useful. Somehow magically reduces the ssao time without changing anything visibly, feels a bit like a bug in the engine.

1 Like

Hi,

One thing you can do is enable some extra trace scopes for your next Unreal Insights capture for added info, try the following on the command-line of your editor/game before taking a trace

-trace=default,memory,loadtime,rhicommands,task -verbosenamedevents

The task scope can be helpful as it allows you to see the links between threads where one thread is waiting on a task from another thread, though in this case I think the rhicommand scope will be most useful as it appears the issue is on the RHI thread and this should add some more details to the trace there.

It looks to me like the game thread is waiting at the end of the frame for the render thread to catch up (game thread is finishing frame 8203, render thread is still working on frame 8202). The 4.4ms stall you highlighted on the render thread during “OcclusionCull” is waiting upon the RHI thread to finish its command list (RHICmdList_FlushRHIThread), it’s doing a flush of the command list meaning it has to wait for all current work on the RHI thread to finish. That means the RHI thread is the issue here rather than the OcclusionCull call, the RHI thread is still busy working away on frame 8201 so it’s two frames behind.

To investigate your RHI thread times, the rhicommand trace scope is a good place to start, but taking a Renderdoc capture or using the built-in GPU visualizer to figure out where the time is being spent on the GPU would be my recommendation.

Hope that helps

“stat uobjects” will show exactly what classes are eating a lot of game thread.