ShouldUseThreadingForPerformance()


bool FApp::ShouldUseThreadingForPerformance()
{
static bool OnlyOneThread =
FParse::Param(FCommandLine::Get(), TEXT("ONETHREAD")) ||
FParse::Param(FCommandLine::Get(), TEXT("noperfthreads")) ||
**IsRunningDedicatedServer()**||
!FPlatformProcess::SupportsMultithreading() ||
FPlatformMisc::NumberOfCoresIncludingHyperthreads() < MIN_CORE_COUNT;
return !OnlyOneThread;
}

why???

this means dedicated server builds are **unable **to make use of asyncTraces or anything to do with taskgraph and async threads… i have tested this and its true, no threading happens in packaged builds.

To save on hosting bills lol

Its very common in dedicated servers (AFAIK epic games does it in fortnite),to not only have the server be singlethread, but run multiple servers per core. Something like you buy a 4 core machine, and host 8-12 servers on it.

It does seem slightly stupid to hard code that instead of simply using the -onethread switch if that’s your desired behavior.

more testing reveals that dedicated servers using taskgraph async do throw it in the taskgraph thread(s)


Async<void>(EAsyncExecution::TaskGraph, =] { abc(); });

and such

however any async trace from GetWorld() does not work as it obeys FApp::ShouldUseThreadingForPerformance()

is it an oversight? maybe somethings just don’t work well in a stripped down build like dediserver?
https://forums.unrealengine.com/core/image/gif;base64
i dont know…
im going to compile the engine without that check in there and see what happens…

update: i removed the line


**IsRunningDedicatedServer()**||

from *FApp::ShouldUseThreadingForPerformance() *with no trouble in sight. I don’t know how complex the game needs to be to start seeing problems but for the moment everything is stable and things like asyncTrace and such running on their own threads fine.