Game Optimization - What is making WaitForTask so long

Hello,

Simple case : i already made a lot of optimization process like texture, streaming, LOD, disable tick etc, i came from 15fps to 100fps

The thing is when i load 100+ actors, my fps are just reduced because, according to the profiler, the task that increase my ms consumption is WaitForTask in Game Thread and also GPU.

this is the case when i put only 5 characters on my map, notice that all character movement, skeletal mesh and all component are not ticking for the NPC, there is no AI, just a skeletal mesh with a blank texture.

Now same thing but with 300 identical characters

  1. what causes these WaitForTask event that take all my precious ms ? i can’t aim for a specific blueprint/function/process/treatment because it is just empty…

2 . And why Frame and Engine loop are not in sync anymore ?
Any idea ?

Thank you for your time !

2 Likes

Have you solved it yet

How’d you go with solving this one?

I ran into a similar issue. Even though I was using the Animation Budget Allocator in Unreal Engine | Unreal Engine 5.3 Documentation, my 400+ NPCs which share the same skeletal mesh/animation blueprint (UE5 Manny) were blowing away my frame budget on the CPU, stuck in synchronization like WaitForTask just as in the OP. I didn’t have tick hooked up to the character, and neither did the third person character which was its base class.

There were two things of note I found:

  1. Default Manny (even the simplified mesh) has terrible LODs out of the box. The furthest LOD is 16,000 triangles, even though at 6,000 triangles you can barely tell a difference just a few dozen steps away. It also only applies the furthest LOD at 0.15 screen size, so even that reduced 16,000 from the original 90,000 rarely gets used unless you’re really far away. If you are using LOD-impacted optimization like Update Rate Optimization, then this will cause problems for you, and adding adequate LODs can help
  2. The profiler insights does a terrible job at accounting for task synchronization in the timing breakdown, but based on the inconclusive results in the profiler, I had a feeling it might have been the camera boom/camera and/or input hooked up to the third person character. Sure enough, when creating a character without either, I went back up to 60 FPS. When I added the camera to my character, it accounted for half of the frame time I was seeing previously, so I suspect the input events or something else in the third person character blueprint is responsible for the other half

Once I spawned my custom character that inherits Character directly instead of the third-person character, the WaitForTask & synchronization all but disappeared from the profiler.

On another note, I’m still missing the 1ms animation budget even with Animation Budget Allocator at full throttle, so there’s probably still room for improving performance even though there’s enough headroom in my game to get 60 FPS for now.

Edit: Another issue I ran into was something to do with physics was missing from the profiler. I had accidentally set the character mesh collision to NoCollision and missed this performance cost in my initial post, but for some reason the CharacterMesh collision eats up a ton of performance even if the NPCs are spread out unlike in the picture above. I still haven’t figured out what I’m going to do to solve this, but you can verify if this is your problem by setting the mesh to NoCollision temporarily and seeing if that brings up your framerate a lot. Like before, for some reason it doesn’t show this in the profiler.