- Home /
Reduce CPU usage of Headless mode
I run a Headless Mode Server on Linux(debian) and doing nothing. It eats about 5% cpu time. I have three question about that.
If I change the "Fixed Timestep" to 1 will fix this problem. What's the bottleneck exactly?
And I found unity has create 28 background thread! How can I reduce that? I try to disable the sound. It reduce to 26...
How can I use profiler on headless mode?
Thank you.
Answer by MCoburn · Nov 18, 2015 at 11:12 AM
Unity3D has a lot of threads in the background to handle a lot of things. Don't ask why... It's just how the engine manages itself. 5% is acceptable, because unless your machine is old, it's really not going to make a dent in performance. If it was doing nothing and eating up around 80% of your CPU, you'd have to question what the heck was going on.
Headless may also use what's known as a virtual framebuffer, as in, rather than using Xorg to pipe the 3D content to your GPU, it's rendering to a memory buffer (which is being done on the CPU) and then being discarded.
I haven't played with Unity's headless mode myself, but I have a decent understanding of Linux knowledge. I'd be willing to bet it's either overhead from the engine, or the virtual framebuffer.
I'm using the Headless $$anonymous$$ode as game server. I want to run dozens of process instance in a single physics machine. In this circumstance the sum Idle CPU usage and thread number become a considerable big usage. (Actually I should run multi scene in one instance. But the design of UNET not allow me to do that...ft... )
What are your machine's specs that you want to deploy the game server on?
A lot of professional game servers actually spawn one instance of the game per server, which is the case in the stand-alone servers of Battlefield and Call of Duty. The only issue there is you'll need to change the ports (maybe via a config file parsed at boot?) so you don't have two server instances trying to fight over the same port.
What you could do, is try disabling the $$anonymous$$ain Camera. It could be to blame, like it's rendering something that is pointless in headless mode. I'm not 100% sure about the "Fixed Timestep" setting so I can't suggest any chances there.
Failing that, it may be a case of having to live with it.
Game server is amazon ec2. About 4 core maybe. $$anonymous$$y game is $$anonymous$$OBA-game like DOTA. One instance that only serve ten people take one machine is unacceptable... 5% cpu per instance will cost 100% by running 20 instance. Only 200 people one machine are still very bad and expensive...