[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Re: 100% CPU



"Nathan" <nathan.stocks@xxxxxxxxx> said:

> Why you would WANT to max out the CPU really baffles me.

Grampa used to chastise me for only using 50% of the length of the
handsaw. He said "I paid for every tooth on the saw blade, use them all."
Wasting (including underusing) the CPU seems like the same thing.

> Some of us (like me) do our pygame programming while the computer is
> doing lots of other stuff.  Personally, it's not uncommon for me to be
> rendering one of my video projects (working on home videos from the
> 90's right now), which takes hours of full-CPU usage.  If my simple
> apps used busy-waiting or any other inane waste-of-cycles, both my
> rendering AND my pygame app would suffer.

Well, sure. If the video rendering takes 100% of the CPU, any game,
regardless of whether it tries to take all CPU cycles available or not,
will suffer.


> Also, the pygame apps I develop go to my daughter's G3 iMac to be
> played.  If they use very much CPU on my MBPro (C2D 2GHz), they're not
> even going to be playable on the G3.

That depends on how it's using that CPU. If it's being intelligent about
scaling its use to the available resources, and if the slower machine is
still within min spec, I don't see any problem.


> So, for me, the two biggest benefits of being efficient with CPU usage

Eh, I wouldn't equate "efficiency" with "100% CPU use". Games can be
inefficient with 20%, or efficient with 100%.


> are 1) Concurrently running programs are affected minimally,

I really don't see this as a compelling use case. Seems like most people
play games in an essentially single-tasking mode. If they're also trying
to run complex calculations in the background, like you are with your
video rendering, that's just sabotaging the other program.

I was considering the comparison of 100% CPU use versus 100% hard drive
use. I could come up with some awfully sketchy examples of cases where a
game might want to expand to fill the hard drive, but given that the
overwhelming majority of people like to have concurrently installed
programs, 100% hard drive use seems like it wouldn't be well accepted.


> and 2)
> the program works great on much slower machines.

Yep, let's totally scale to use 100% of the CPU all the way down to the
min spec. I agree.


> I mean, I can understand USING the cycles to achieve some desired
> benefit.  What benefit is there to wasting CPU cycles in a

By definition, wasting cycles is bad, and if the CPU is running at 25%,
that would be 75% waste, right?


> To me, a program that maxes out the CPU
> is a sign of bad programming, unless that program actually makes good
> use of all the cycles that it gets.

Absolutely, wasting resources is bad programming.


There are a lot of applications for scalable use of CPU - but I
acknowledge that not every game needs any of them.

AI (opponents) - the more processing power available, the more challenging
play.

AI (NPCs) - in many games, there are computer-controlled entities that are
not strictly opponents. These might be townspeople milling about, or
animals in the background. This adds to the feeling of immersion in role
playing games.

Physics - the more CPU available, the higher the fidelity of the physics
simulation that can be run.

Graphics Structure Maintenance - there are a number of graphics algorithms
that require periodic processing, like adaptive terrain rendering. The
more CPU you can feed it, the more accurate the terrain approximation is.

Resource Loading - if you want to pull large amounts of data off of
storage, you may find that storing the resources in a compressed format,
and using the CPU to decompress the assets reduces load time. If you have
CPU available to you, you might even be able to do this load before the
new assets are needed, which could speed up your transitions between
levels.



For the exceptional cases where people don't have a full CPU to give over
(either because the full CPU comes at unacceptable current draw costs for
notebooks, or because they want to play while an important background
process eats a fraction of the CPU) I can see a special option to allow
the game to artificially scale down to less than 100% CPU - that sounds
like a great way to give the players the power to play the game the way
they want to.

But I wouldn't jump to the conclusion that just because the whole second's
worth of CPU cycles is used by the end of the second, that anything's been
wasted. Heck, if my bank threw away all the money in my bank account at
the end of the month, I'd be really careful to spend as close as possible
to 100% of my paycheck.


-Dave LeCompte