Forum

Idea - Throttling the Server

Discuss programming topics for the various GPL'd game engine sources.

Moderator: InsideQC Admins

Postby Baker » Sat Sep 11, 2010 10:49 pm

mh wrote:It will always use 100% CPU (or 100% of a core) even with this, and that's just the nature of a game loop, and is actually a highly desirable trait in a game loop. Anything that spins constantly without a sleep each iteration will chew your CPU, even this:
Code: Select all
while (1);
The reason why it's desirable is so that the code can react as soon as possible to unpredictable events, such as when the user is going to press a mouse button or a key. As the very least you need to spin while retrieving time.

I've seen working examples where the coder has tried sending a game to sleep for a bit through each iteration of the loop, out of a mistaken idea that using less CPU is somehow a good thing, and to be honest the only end result is jerky input and inconsistent performance. A game is one type of app where you most definitely do want to be using as much CPU as you possibly can. that's the definition of a "real time application". You need that CPU to be constantly busy doing stuff. Believe me, people have written books about this, it's a given, accepted fact.


Well, for a client maybe but for a dedicated server that may be on a Windows box with 20-30 other servers having the dedicated server limit itself to realistic CPU usage is very important.

I don't say "maybe" above regarding the client because I disagree about how a fullscreen client should use all the CPU it can, but rather there may be circumstances or sitations where this isn't desireable that aren't immediately obvious.

I do know that I've made great efforts to ensure that, for example, ProQuake is using almost no CPU when it is minimized and I haven't at this point thought about CPU usage when the client is pause (or maybe I did and just forgot) or doesn't have the focus.
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Postby mh » Sun Sep 12, 2010 12:17 am

When minimized/paused/etc it should Sleep on every iteration through the loop so as to give the CPU back to the OS. Actively running is what I'm talking about here, and that's where you need all the CPU you can get.

Dedicated servers are a whole other story that need to obey a different set of rules, and none of this stuff should apply to them. They should run at the steady 72 FPS rate (or whatever the server administrator decides).
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Postby r00k » Sun Sep 12, 2010 7:15 am

I tested it out briefly in Qrack, and it works though the particle timings are off, and levelshots are fubared etc.. just needs tweaking to sync everything i suppose :D but at least i get 208 fps in singleplayer vs frikbots!
r00k
 
Posts: 1110
Joined: Sat Nov 13, 2004 10:39 pm

Previous

Return to Engine Programming

Who is online

Users browsing this forum: No registered users and 1 guest