We would like to fully manage what threads certain tasks get assigned to, what is the preferred method of doing this?

We have had some success using thread affinity via GetTaskGraphThreadMask and GetTaskGraphBackgroundTaskMask so that foreground and background workers are on different threads. Then using “ThreadPriority” to try and select foreground or background workers. But have noticed that high priority tasks can still run on background workers.

Also with the new TaskGraph backend the GetTaskGraphHighPriorityTaskMask seems to no longer be used hence we can’t use that to force high priority tasks to their own threads.

The reason for this is that we’d like to keep RHI translate and animation tasks on separate clusters for consoles to improve cache usage.

Hi Andrew,

There is currently no way to accomplish what you want without substantial changes to the engine.

The closest you could get would be to prevent background workers from running foreground tasks, but its probably going to cost you more performance than the cache misses.

If you are curious to try it, you can modify LocalQueue.h and rework the StealLocal and Dequeue to not pickup foreground work when GetBackGroundTasks is true.

Hope this helps,

Danny

Thx Danny yeh will take a look

Hi Andrew,

Happy to hear that!

Thanks for letting us know!

Danny

Just a quick update, we did try the change recommended to prevent foreground tasks from migrating to background and can confirm this does not help. We did try increasing the number of foreground workers from 2 to 4 which improved things. But despite trying various thread affinity settings in order to keep systems running on the same cluster (consoles only) including this change we are not able to improve CPU performance over the default setup. So have come to the conclusion that the hardware knows what its doing and manages cache usage and balances core work loads really well.

This ticket can be closed, thanks for the suggestions.