HowTo: Make Ren'Py's CPU usage sane

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Message
Author
delta
Epitome of Generic
Posts: 525
Joined: Sat Dec 22, 2007 12:59 pm
Projects: yes
Contact:

HowTo: Make Ren'Py's CPU usage sane

#1 Post by delta »

http://renpy.org/wiki/renpy/doc/referen ... _Variables
Variable: config.framerate = None

If not None, this is the upper limit on the number of frames Ren'Py will attempt to display per second.
I would urge EVERY user of Ren'Py to set that config variable to some sane amount (30 - 60), because the default is a bad idea. The reason? Ren'Py will otherwise just blindly take the whole processor (or core) when any kind of animation plays. This includes stuff like animated CTC indicators. And that will probably kick CPU fans into high gear and drain laptop batteries, fast. For no reason.

Me and renpytom have some kind of disagreement over this, because he thinks that "games should use everything there is" and "idle CPU cycles are wasted", which is... debatable, to say the least. Other people I talked about had less benevolent words to say.
The rest is left as an exercise for the reader.

Jake
Support Hero
Posts: 3826
Joined: Sat Jun 17, 2006 7:28 pm
Contact:

Re: HowTo: Make Ren'Py's CPU usage sane

#2 Post by Jake »

delta wrote: Me and renpytom have some kind of disagreement over this, because he thinks that "games should use everything there is" and "idle CPU cycles are wasted", which is... debatable, to say the least.
I tend to agree. Although I'd just say "set it to 60 all the time and leave it there".

I was told (during my university's Computer Graphics course, while discussing framerates, would you believe?) that the typical human eye tends not to register movement faster than about a thirtieth of a second, so there's little point for most people in framerates above 60FPS.

Some people have bad subconcious reactions to flickering at frequencies up to 80 or 90 Hz, but the framerate of a game and the refresh rate of a monitor are two totally different things, and I believe lower framerates don't tend to produce the same effect. I've known a couple of people who insisted on having their monitors refreshing at 100Hz to avoid headaches but had no trouble watching DVD videos on them once they'd set them that way, for example.

If the user thinks that their idle CPU cycles are wasted, then they're free to chew them up on folding@home or SETI or whatever; I don't see the point burning through people's laptop batteries in order to render another hundred frames a second that they're never going to see anyway.
Server error: user 'Jake' not found

delta
Epitome of Generic
Posts: 525
Joined: Sat Dec 22, 2007 12:59 pm
Projects: yes
Contact:

Re: HowTo: Make Ren'Py's CPU usage sane

#3 Post by delta »

And that's only true for CRTs. Flat panels almost never run above 60 Hz. The flickering is because CRTs have much less afterglow.

Not to mention that there isn't really such a thing as "wasted cycles" on modern CPUs, because they have the HLT instruction or even clock down.
The rest is left as an exercise for the reader.

Jake
Support Hero
Posts: 3826
Joined: Sat Jun 17, 2006 7:28 pm
Contact:

Re: HowTo: Make Ren'Py's CPU usage sane

#4 Post by Jake »

delta wrote:And that's only true for CRTs. Flat panels almost never run above 60 Hz. The flickering is because CRTs have much less afterglow.
Well, strictly speaking LCDs don't have afterglow at all, since they're lit continuously from behind.

A friend of mine who's sensitive to these things has no trouble watching things on my plasma TV (Panasonic Viera from about a year and a half ago), but he's renting the next model up from mine and apparently he gets headaches looking at it for too long and can see a faint flickering.

But regardless, it's a completely separate issue from game framerate anyway. ;-)
Server error: user 'Jake' not found

EvilDragon
Veteran
Posts: 284
Joined: Fri Dec 28, 2007 5:47 am
Location: Where the Dragons rule!
Contact:

Re: HowTo: Make Ren'Py's CPU usage sane

#5 Post by EvilDragon »

ESPECIALLY in the VN environment, high framerate isn't something that your life would depend on. It's a quasi-static media, for God's sake. Now, if it were a shooter, that would be a different thing. I totally agree with delta and his opinions on CPU usage.
Angels of paradise, angels of sacrifice
Please let me be under your wings...

monele
Lemma-Class Veteran
Posts: 4101
Joined: Sat Oct 08, 2005 7:57 am
Location: France
Contact:

Re: HowTo: Make Ren'Py's CPU usage sane

#6 Post by monele »

I agree too. I understand why a full 3D FPS would run at 100%, but a VN... except for when it animates fullscreen, it shouldn't be useful. So yeah... I guess this config var should be set o_O... Though I'm pretty sure I'll forget it most of the time ~_~

Jake
Support Hero
Posts: 3826
Joined: Sat Jun 17, 2006 7:28 pm
Contact:

Re: HowTo: Make Ren'Py's CPU usage sane

#7 Post by Jake »

monele wrote:I agree too. I understand why a full 3D FPS would run at 100%
To be honest, I don't think there's really much point running a 3D FPS at 100% CPU, either; if you go above ~60FPS you're still going to be rendering frames that the user can't see. (Particularly there's literally no point rendering frames faster than the refresh rate on the video mode.)

The only place I can think of that it might be considered worthwhile is if you're doing a physics-based application and tie your physics frames to your display frames, in which case the higher the framerate the shorter the duration of each individual frame so the less likely you are to have an entity pass straight through another one because it was moving so fast it was on one side one frame and the other side the next. But really, it's probably a better idea to fix your physics code so it's time-independent.
Server error: user 'Jake' not found

monele
Lemma-Class Veteran
Posts: 4101
Joined: Sat Oct 08, 2005 7:57 am
Location: France
Contact:

Re: HowTo: Make Ren'Py's CPU usage sane

#8 Post by monele »

I just meant that I would understand if a FPS ate 100% of my CPU, because I expect an FPS to need lots of calculation that might warrant a more or less constant 100%. If I boost my CPU or Graphic card, though, I wouldn't understand if it kept eating 100%. The 100%, to me, seems to mean "you have reached the limit of your computer, ahead lay the abyss" :)

Aenakume
Regular
Posts: 182
Joined: Mon Aug 11, 2008 4:38 am
Projects: Arts... i hate arts -_-
Contact:

Re: HowTo: Make Ren'Py's CPU usage sane

#9 Post by Aenakume »

monele wrote:I just meant that I would understand if a FPS ate 100% of my CPU, because I expect an FPS to need lots of calculation that might warrant a more or less constant 100%. If I boost my CPU or Graphic card, though, I wouldn't understand if it kept eating 100%. The 100%, to me, seems to mean "you have reached the limit of your computer, ahead lay the abyss" :)
A lot of the more modern game engines scale, which means that they will use everything your system has to do as much as possible. If you upgrade your system, it gets more time in between frames to do more work - like more fine-grained AI tactical calculations, fancier environmental effects, better physics, that kind of thing.

i dunno if free engines like CrystalSpace, OGRE or Irrlicht do that, but i know Quake 2 and 3 engines do. It's not hard to do in theory: if you make the engine in two threads, one to render and one to do all the physics and AI, then you can just have the display thread locked to ~60 fps and the other thread unbounded. On a slower machine the second thread completes once every frame (at least, for it to be playable), on a faster machine it may complete a dozen times per frame. On the slow machine you might not "notice" impacts until the person's nose is already a few centimetres inside the wall, but on the faster machine, you catch on a lot quicker. Course, things get complicated when you bring in multi-player, but then they always do.

Course, if you're playing a FPS made in 2000 and you have a modern, 2008 computer and it's still eating up the whole CPU, it's just being greedy.
“You can lead a fool to wisdom, but you cannot make him think.”

Adorya
Miko-Class Veteran
Posts: 541
Joined: Fri Aug 18, 2006 4:51 pm
Contact:

Re: HowTo: Make Ren'Py's CPU usage sane

#10 Post by Adorya »

Yes, older apps made to be entirely dedicated to the computer (aka no alt-tab) will try to hog all that he can, perfect exemple is Shandalar, which is a simple Magic card game with no fancy graphics but will make any cpu throttle at 100%

User avatar
PyTom
Ren'Py Creator
Posts: 16097
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: HowTo: Make Ren'Py's CPU usage sane

#11 Post by PyTom »

Hm... some convincing arguments here. I'm strongly considering releasing a 6.7.1b that has config.framerate set. But I'm wondering if it should be set to 30 or 60fps. (Or some other number.) Thoughts?
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

monele
Lemma-Class Veteran
Posts: 4101
Joined: Sat Oct 08, 2005 7:57 am
Location: France
Contact:

Re: HowTo: Make Ren'Py's CPU usage sane

#12 Post by monele »

I don't remember : does it force this framerate if the computer can't follow? I mean, if a game runs only at 40fps on a certain computer, does it get even worse if the game is set at framerate 60?
If so, I'd suggest 30 as it's well enough for most games and most players, and games that really *need* these extra frames can be set up so.
If it doesn't change a thing, better go with the highest setting and let slower computers.... be slow :)

User avatar
PyTom
Ren'Py Creator
Posts: 16097
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: HowTo: Make Ren'Py's CPU usage sane

#13 Post by PyTom »

No, the framerate is the maximum. If the computer can't keep up, Ren'Py will go with the current behavior, which is to try to show things as fast as it can.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Jake
Support Hero
Posts: 3826
Joined: Sat Jun 17, 2006 7:28 pm
Contact:

Re: HowTo: Make Ren'Py's CPU usage sane

#14 Post by Jake »

PyTom wrote: But I'm wondering if it should be set to 30 or 60fps. (Or some other number.) Thoughts?
Presuming my Computer Graphics lecturer wasn't just spouting rubbish when he gave the 30Hz equivalence figure for the human eye, then Nyquist and Shannon say 60fps.

(I'd guess this is probably also the reason that framerates of TV standards tend to be 50-60Hz (after interlacing) - the people engineering them probably just kept turning them up until the movement looked smooth enough to everyone in the room at the time. ;-) )

As it goes, another interest of mine - as people who've been around here for very long probably realise - is the 2D shooter genre; in hobbyist shooter circles, it's pretty much a given that targetting your framerate (or even locking it) at 60fps is 'the right figure'.
Server error: user 'Jake' not found

denzil
Veteran
Posts: 293
Joined: Wed Apr 20, 2005 4:01 pm
Contact:

Re: HowTo: Make Ren'Py's CPU usage sane

#15 Post by denzil »

+1 to limiting the default framerate

And I'll just note that (AFAIK) movies in cinemas are running at 24 fps. If someone wants to run action mini-game or something in Ren'Py then 60 fps would be probably better, but just for VNs 30 fps will be probably more than enough. But in the end you can just always try both and see which one is better.
Practice makes purrrfect.
Finished projects: Broken sky .:. colorless day .:. and few more...

Post Reply

Who is online

Users browsing this forum: Google [Bot]