Author Topic: 100% Cpu Usage All Time !?  (Read 4147 times)

Offline geoslake

  • Newbie
  • *
  • Posts: 7
100% Cpu Usage All Time !?
« on: November 28, 2007, 12:09:35 PM »
hi

Just discovered this great game.
I'd like to run it on my laptop, but it uses 100% cpu power, while it should use far less.
(which leads to heavy heat and fan speed/noise)
Would it be possible to allow cpu idle ? (like many other 2d games do - openttd, urquan master, even lfs etc)

thanks

Offline Hidiot

  • Hero Member
  • *****
  • Posts: 1018
100% Cpu Usage All Time !?
« Reply #1 on: November 28, 2007, 02:15:25 PM »
Um... a lot of things use the CPU. Unless it runs slower than it should, there shouldn't be a problem. If the fan is bugging you, clean it or buy a new one.
"Nothing from nowhere, I'm no one at all"

Offline geoslake

  • Newbie
  • *
  • Posts: 7
100% Cpu Usage All Time !?
« Reply #2 on: November 28, 2007, 03:58:34 PM »
Quote
clean it or buy a new one

I understand your nick name now.
Ok i explain especially for you. Laptop run on battery, right ?
100% cpu usage means, hot laptop on my legs, it also means the battery empties itself quickly.

My question was "Would it be possible to allow cpu idle ?", i'm not asking for a fan cleaning kit, thanks.

Offline Mcshay

  • Administrator
  • Sr. Member
  • *****
  • Posts: 404
100% Cpu Usage All Time !?
« Reply #3 on: November 28, 2007, 05:04:06 PM »
Outpost 2 doesn't use 100% CPU power all the time, it only uses what it needs (it only uses 30% of my CPU). It seems that your computer is very, very old/slow because you need 100% CPU power to run a 10 year old game...

Turning down the game speed might help, but not much if at all.
« Last Edit: November 28, 2007, 05:04:39 PM by Mcshay »

Offline Hidiot

  • Hero Member
  • *****
  • Posts: 1018
100% Cpu Usage All Time !?
« Reply #4 on: November 29, 2007, 01:39:34 AM »
Uh... my bad... forgot you were talking about a laptop  :huh:

Last time I checked, my computer uses 100% CPU to run OP2, but that's just to make it run as fast as possible.

Sorry, no help here...
"Nothing from nowhere, I'm no one at all"

Offline geoslake

  • Newbie
  • *
  • Posts: 7
100% Cpu Usage All Time !?
« Reply #5 on: November 29, 2007, 01:50:16 AM »
Quote
Outpost 2 doesn't use 100% CPU power all the time, it only uses what it needs (it only uses 30% of my CPU).

Mmmm, are you sure ? Im talking about when i actually play, not when in the menu or something...
« Last Edit: November 29, 2007, 01:50:48 AM by geoslake »

Offline Leviathan

  • Hero Member
  • *****
  • Posts: 4055
100% Cpu Usage All Time !?
« Reply #6 on: November 29, 2007, 05:08:04 AM »
Yea Outpost 2's CPU useage allways confused me.

But fact is, its not using 100% CPU even if it says it is.

Offline geoslake

  • Newbie
  • *
  • Posts: 7
100% Cpu Usage All Time !?
« Reply #7 on: November 29, 2007, 05:48:53 AM »
Quote
Yea Outpost 2's CPU useage allways confused me.

But fact is, its not using 100% CPU even if it says it is.
If windows task manager says it does use 100%, it surely does :)

Offline Eddy-B

  • Hero Member
  • *****
  • Posts: 1186
    • http://www.eddy-b.com
100% Cpu Usage All Time !?
« Reply #8 on: November 29, 2007, 06:05:14 AM »
I've always been confused by CPU usage..
AFAIK the pentium does not have a SLEEP instruction or something alike.. so what does it do when it's not using the CPU ?
Rule #1:  Eddy is always right
Rule #2: If you think he's wrong, see rule #1
--------------------

Outpost : Renegades - Eddy-B.com - Electronics Pit[/siz

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
100% Cpu Usage All Time !?
« Reply #9 on: November 29, 2007, 06:18:41 AM »
Hmm, I get 100% CPU usage as well.


The pentium does have a few power down related instructions, but for obvious reasons, these tend to be priviledged instructions.

I think Windows will issue power down code when it sees CPU usage is low. (According to the task manager, and how often there is nothing to schedule other than the idle thread).


I believe the use of the Sleep Windows API call will generally decrease the CPU usage, if used properly. OP2 seems to make somewhat odd use of Sleep and threads though. I suspect what really happens is at least one thread is always running, and possibly stuck in some sort of busy loop (perhaps waiting for other threads, or waiting for enough time to elapse). At least while a game is active. The CPU usuage remains fairly low at the main menu and such. I'd never actually really noticed the high CPU usage before. The thing is, the game isn't actually that busy, so you can run lots of other things at the same time, and they'll all take whatever they need, and OP2 will happily run on what's left. But it does seem to consume whatever is left available. Not so good for battery use on a laptop.

I'd had thoughts of mucking with the Sleep calls in the network code in an attempt to reduce lag. It actually uses Sleep with a non zero parameter between checking network buffers. I was a little concerned about timing issues (maybe the game depended on that to run at the correct speed?), although I thought CPU usage might be more of a concern. But, since it's apparently already at 100%, I might as well go ahead and edit away.


Btw, this is an excellent reason why you should never code busy wait loops (among a number of other reasons). I remember some early version of RiddleHack that was posted on here had this issue. I promptly complained about the CPU usage on that one. If you need a timing delay loop, make sure it calls Sleep.
« Last Edit: November 29, 2007, 06:20:59 AM by Hooman »

Offline BlackBox

  • Administrator
  • Hero Member
  • *****
  • Posts: 3093
100% Cpu Usage All Time !?
« Reply #10 on: November 29, 2007, 09:49:44 AM »
Quote
AFAIK the pentium does not have a SLEEP instruction or something alike..
Generally the OS executes the HLT instruction when it is not doing anything. This really isn't of any concern to the application developer (since HLT is a privileged instruction). Basically, it HLT's if there are no tasks ready to run (i.e. all tasks are waiting for I/O completion).
And yeah, Sleep() will put the current thread into a sleeping state (the OS scheduler will run other threads if any are ready).

Technically though, OP2 *should* idle during the message loop (not sure why it actually isn't). GetMessage() is a blocking call and the thread should be put into some sort of non-running state (probably alertable wait) when waiting for messages to arrive to the window procedure.

I don't know about the network code however...

The technical stuff aside, I've personally not seen 100% CPU usage when Outpost 2 is running for me (and I have a laptop). One thing you might do to decrease the issues with it for now is to use some sort of CPU speed / frequency scaling control to decrease the CPU speed when the game is running, in order to get better battery life.

Offline geoslake

  • Newbie
  • *
  • Posts: 7
100% Cpu Usage All Time !?
« Reply #11 on: November 30, 2007, 02:45:19 AM »
I cannot say i understand everything has been said, but, at least for 3d games, they usually all use 100% cpu, because gamers may want the highest frame rate as possible.
For 2d games, i guess its about the same, so once they reach, say, 60 frames per second, theres no need for more (60 is already an awful lot), even if cpu could actually render 300fps more...

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
100% Cpu Usage All Time !?
« Reply #12 on: November 30, 2007, 05:56:27 PM »
Yes, but the wrong game design could cause it to eat more processor time than it really needs. Particularly when that CPU time is available.

Basically it seems to be a flaw of the game design, and there isn't really anything we can do to fix it. We might look into it sometime, and perhaps make a patch, but don't expect anything soon (if at all).
 

Offline geoslake

  • Newbie
  • *
  • Posts: 7
100% Cpu Usage All Time !?
« Reply #13 on: December 03, 2007, 02:56:24 PM »
But almost all games behave like that, either 3 or 2d, so its usually on purpose, just to get highest fps. Of course for such a game, its stupid.
If there were a way to prevent the game to compute more than 60fps, that would be nice.

Anyway, thanks for answering :)

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4955
100% Cpu Usage All Time !?
« Reply #14 on: December 04, 2007, 03:07:33 AM »
Well that's the thing. I'm pretty sure OP2's frame rate is locked to something like 30. (I don't know the exact number off hand, but I think I posted some stuff somewhere that lets you calculate it). There's no reason for it to even attempt to draw any more often than that during a normal game cycle. It might do some extra draw if the game window was just uncovered after being partially blocked by another window, but that doesn't typically happen very often.

At any rate, it does seem to take 100% CPU usage, and there isn't really anything we can do about it.
 

Offline geoslake

  • Newbie
  • *
  • Posts: 7
100% Cpu Usage All Time !?
« Reply #15 on: January 21, 2008, 08:48:51 AM »
ah ok :(

I thought you had game sources or something...

thanks anyway