Hey all Ive recently made a dedicated server for my game (empty scene with the server script). all that is being executed is the initial Network.InitializeServer(..) function and all that gets looped is the GUI. My question is this: Im seeing a 40% - 50% CPU usage on both my cores. Is this normal ? , if so .. why ? Is there a way to lower usage ? and how mush is it going to increase with incoming connections. Thanks
Is this on mac or windows? On mac you can run somewhat of a dedicated server, on windows this will be possible in 2.6. See batchmode: http://unity3d.com/support/documentation/Manual/Command Line Arguments.html Per default I believe the update rate isn't limited, so you should cap your framerate on the server to reduce CPU usage.
Its on Mac my camera isnt even rendering (disabled, no Framerate) just a GUI on a very odd looking (640x480) frame.
you can hook in the performance analyze tools and profiling and you will see what eats the time. My guess goes towards: a large amount is eaten by graphics and sound. Also, with a single gui in place, you actually have a full 3D scene.
Im starting to assume that 40-50% isnt normal ??? can anyone tell me this for a fact ? Ok, full 3D scene but no audio sources or draw Calls, not a single poly... im thinking that this seems like a infLoop but, not in my code, i looked. but surely the Network Server function uses a lite thread with a decent wait so it cant be that, can it ? Can the OnGUI() function be slowed down ? To do like 5 Draws a second or something ?
No, i saw earlier posts of jashan were he reported the same problem: The game will just fill up the CPU to get an as high possible framerate. Therefore you need to limit your framerate. There was a very easy trick for this... Edit: See the last post here: http://forum.unity3d.com/viewtopic.php?t=17700&highlight=fps+cpu
[Solved] So this is what happened: Because there was noting taxing in my scene i was getting a frame rate of 800+. This caused the GUI to be drawn 800+ times a second, which gave me a 50% CPU usage. After using a sleep Code (csharp): System.Threading.Thread.Sleep(1000/capFps); at capFps = 12 I was using 5% CPU. Thanks Guys.
Hehe, yeah - I really liked the server framerates of 1000+ on my server, too ;-) I think Unity 2.5 introduced a new feature that allows you capping the framerate. I'd assume that the Sleep(...) approach does essentially the same, but it might be nicer to use that new feature. ... which is called ... um ... there we go: From: UNITY: What's New in Unity 2.5 Ah, and here's the API documentation