How to Specify number of Task Graph threads (NumNamedThreads)

I see a few ways to brute force this in TaskGraph.cpp, ie:

NumNamedThreads = LastExternalThread +1;
to
NumNamedThreads = 4

or change

NumThreads =
FMath::Max(FMath::Min(NumTaskThreads

  • NumTaskThreadSets + NumNamedThreads, MAX_THREADS), NumNamedThreads + 1);
    to
    NumThreads = 4

but I assume there is a more elegant override somewhere and was hoping that someone with experience here could guide me in the right direction

Pre-empting the ‘why would you want to do this’ question, there are situations where decreasing the number of task threads would be beneficial, say you are running a docker container that only has access to 6 out of the 8 cores on the system as you’ve pinned 2 cores to the system. UE4 is going to see 8 cores and think, great I’ll leave one of these for the OS, 1 for the game thread, 1 for the physics thread and I’ll have 5 available for TaskGraph, when in fact it is only going to have 4 cpu’s available for 5 async task threads, meaning 2 of those threads are going to be sharing the same core, which is terrible.

One suggestion on discord(thanks Phy) was to change these values