Idea - Throttling the Server
Moderator: InsideQC Admins
18 posts
• Page 2 of 2 • 1, 2
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: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.
- Code: Select all
while (1);
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?
Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
-

Baker - Posts: 3666
- Joined: Tue Mar 14, 2006 5:15 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).
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
We knew the words, we knew the score, we knew what we were fighting for
-

mh - Posts: 2292
- Joined: Sat Jan 12, 2008 1:38 am
18 posts
• Page 2 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 1 guest