Consoles return false for IsGameOnly

We have some code that makes use of the thread pool. It detects how many threads have been spawned and issues one job for each thread to maximise parallelism. I was doing some profiling on Xbox One and found out that there are 6 pool threads (which makes sense since it has 7 cores available), but they are affinitised to run on cores 3, 4, 5 and 6. This causes our code to issue 6 evenly sized jobs which are then run on only 4 cores, which is quite inefficient, as you can imagine.

It seems like the intention is to only spawn 4 pool threads, but it ends up spawning 6 by accident. The code that determines how many threads to spawn is in FGenericPlatformMisc::NumberOfWorkerThreadsToSpawn. It limits the number of pool threads to 4 if IsRunningGame() returns true, but this actually returns false on XboxOne (and most likely PS4 as well, although I haven’t tested it).

The problem seems to be in FGenericPlatformProperties::IsGameOnly(), which returns false and is not overridden in FXboxOnePlatformProperties. Some platforms, such as Android, have their IsGameOnly implementation return UE_GAME, which is presumably defined to 1 in game-only platforms.

This seems like it would be a good default, so I was wondering if you’d consider changing FGenericPlatformProperties::IsGameOnly to return UE_GAME to fix this problem. Does that sound reasonable? An alternative would be to override it in FXboxOnePlatformProperties and return true from there.

Hi Henry. This was an oversight in the Xbox One platform properties. Thank you for pointing it out. We’ll get that fixed up. FXboxOnePlatformProperties should simply have an override of IsGameOnly that returns true (PS4 already does this).

You may also find it useful to use the console command TaskGraph.NumWorkerThreadsToIgnore # to vary the number of task threads to find what gives you the best performance per platform and override NumberOfWorkerThreadsToSpawn on a per platform basis to adjust the number of available worker threads to your title’s best performance on a per platform basis.