ScummVM, powertop, and power usage

General chat related to ScummVM, adventure gaming, and so on.

Moderator: ScummVM Team

Post Reply
fabio
Posts: 18
Joined: Sat May 13, 2006 8:33 am

ScummVM, powertop, and power usage

Post by fabio »

Hi,
some time ago Intel developed a tool to detect power usage of application under linux: powertop http://www.linuxpowertop.org/ .

Note that it works with detailed information only with kernel 2.6.21 and later (works well in latest Fedora Core).

After the release of the tool there were found a lot of application which does not work well (they have a number of wakeups too high, which don't let the CPU go in low power modes, look http://bugzilla.redhat.com/bugzilla/sho ... ?id=204948 for bug reports and how they were fixed). The worst application tipically have 10 wakeups/s, which could reduce power battery of about 15 minutes.

I tried powertop with ScummVM (both 0.9.1 in F7 and svn revision 28702), and this is what I get:

Code: Select all

  93,7% (1069,4)           scummvm : do_nanosleep (hrtimer_wakeup) 
Over 1000 wakeups/s (even during the game selection screen when doing nothig) :shock: . This is killing notebook battery. Would be nice if someone could fix this for next release.
fingolfin
Retired
Posts: 1452
Joined: Wed Sep 21, 2005 4:12 pm

Post by fingolfin »

Sure would be nice, but would also require substantial deep changes to the code -- at least that's my (educated guess). Of course, then again, the information "there is some kind of problem" is not really quite sufficient to figure out what exactly it is and what to do about it ... ;)
User avatar
knakos
ScummVM Porter
Posts: 423
Joined: Wed Nov 02, 2005 2:35 pm
Location: Athens, Greece

Post by knakos »

Note that the programs on that list are "desktop-grade", responding that is to events happening roughly with 1 sec resolution. ScummVM is a real-time, "game grade" application so it is expected to exercise the CPU more heavily than other applications (I'd say with in general 1-20ms resolution, so ~1000 context switches sounds about right, perhaps a little elevated). So the comparison is not fair. Still, aside the fact of the numerous interrupts (context changes) per second, it is obvious from the very low CPU usage that ScummVM forfeits the greater part of its timeslice to the OS, thus being a light load for the CPU. Also in support of this is the fact that ScummVM runs full speed on relatively underpowered devices (with 100MHz CPUs).

I suppose there are not many techniques to minimize the number of wakeups/sec except than batching them together for execution. As Fingolfin suggests this is an "interesting" exercise for coding a game :)

My personal preference is that the CPU is burned to ground when running a game, in so far as I get the best and most fluent gaming experience :)
fabio
Posts: 18
Joined: Sat May 13, 2006 8:33 am

Post by fabio »

knakos wrote:Note that the programs on that list are "desktop-grade", responding that is to events happening roughly with 1 sec resolution. ScummVM is a real-time, "game grade" application so it is expected to exercise the CPU more heavily than other applications (I'd say with in general 1-20ms resolution, so ~1000 context switches sounds about right, perhaps a little elevated). So the comparison is not fair. Still, aside the fact of the numerous interrupts (context changes) per second, it is obvious from the very low CPU usage that ScummVM forfeits the greater part of its timeslice to the OS, thus being a light load for the CPU. Also in support of this is the fact that ScummVM runs full speed on relatively underpowered devices (with 100MHz CPUs).

I suppose there are not many techniques to minimize the number of wakeups/sec except than batching them together for execution. As Fingolfin suggests this is an "interesting" exercise for coding a game :)

My personal preference is that the CPU is burned to ground when running a game, in so far as I get the best and most fluent gaming experience :)
I would not call ScummVM a true Real time application.
However, even if I agree this is not an easy work, I think it should be possible to remove the polling timer with an event driven system. I have indeed tried other similar application (e.g., the Gnash Flash Player with some flash game) that don't exibit this behavior.
User avatar
md5
ScummVM Developer
Posts: 2250
Joined: Thu Nov 03, 2005 9:31 pm
Location: Athens, Greece

Post by md5 »

Please elaborate why you believe that ScummVM is not a soft real-time application :?
User avatar
exofreeze
Banned
Posts: 153
Joined: Thu Mar 09, 2006 1:06 am
Location: Dallas, TX
Contact:

Post by exofreeze »

maybe it's turn based?? lol
fabio
Posts: 18
Joined: Sat May 13, 2006 8:33 am

Post by fabio »

md5 wrote:Please elaborate why you believe that ScummVM is not a soft real-time application :?
Well, I was referring at the game chooser screen that also exibit the high number of wakeups.
fingolfin
Retired
Posts: 1452
Joined: Wed Sep 21, 2005 4:12 pm

Post by fingolfin »

As I said, it wouldn't be impossible to "fix" this "problem", at least in the launcher dialog, but it would require quite deep changes (including extending the backend API). It may also be possible to soften the issue in some, but not all, of the game engines. But that would require changes to each of these.

I don't say it's not a worthy goal, but given the difficulty of the task, and the unclear possibly gain (if we only are able to improve the situation in the launcher -- is it then actually worthing doing at all?), this is a rather low priority thing. We certainly accept patches, though :-).

Though now that I think about it, the launcher GUI code should actually not have to wakeup that often. My guess would be that this is the TimerManager, which runs at a fixed millisecond wakeup interval. If that is true, we might be able to fix that particular part of the issue eventually. You could help by verifying whether this is the cause or not, by temporarily commenting out line 137 in backends/platform/sdl/sdl.cpp (i.e. the call to SDL_AddTimer). Does that help?
fabio
Posts: 18
Joined: Sat May 13, 2006 8:33 am

Post by fabio »

fingolfin wrote:Though now that I think about it, the launcher GUI code should actually not have to wakeup that often. My guess would be that this is the TimerManager, which runs at a fixed millisecond wakeup interval. If that is true, we might be able to fix that particular part of the issue eventually. You could help by verifying whether this is the cause or not, by temporarily commenting out line 137 in backends/platform/sdl/sdl.cpp (i.e. the call to SDL_AddTimer). Does that help?
Hi, I have tried your suggestion with SVN revision 31106. I did the test using an Ubuntu 7.10 (my previuos post was done with a Fedora 8). Seems, however, that it's the same as before:

Original, in the launcher:

Code: Select all

61,3% (979,9)           scummvm : do_nanosleep (hrtimer_wakeup)
Without the call to SDL_AddTimer in backends/platform/sdl/sdl.cpp :

Code: Select all

61,3% (974,9)           scummvm : do_nanosleep (hrtimer_wakeup)
I'll also attach the output of my ./configure (in case this is relevant):

Code: Select all

$ ./configure 
Running ScummVM configure...
Looking for C++ compiler... g++
Checking for compiler version... 4.1.3, ok
Checking endianness... little
Type with 1 byte... char
Type with 2 bytes... short
Type with 4 bytes... int
Running on x86... yes
Checking hosttype... linux-gnu
Alignment required... no
Checking whether building plugins was requested... no
Checking for Ogg Vorbis... yes
Checking for Tremor... no (Ogg Vorbis/Tremor support is mutually exclusive)
Checking for FLAC >= 1.0.1... no
Checking for MAD... no
Checking for ALSA >= 0.9... no
Checking for zlib... yes
Checking for libmpeg2 >= 0.3.2... no
Checking for libfluidsynth... no
Checking for nasm... not found

Engines:
    SCUMM [all games]
    AGI
    AGOS
    Cinematique evo 1
    Gobli*ns
    Legend of Kyrandia
    Lure of the Temptress
    Parallaction
    Flight of the Amazon Queen
    SAGA
    Beneath a Steel Sky
    Broken Sword 1 (without mpeg2 cutscenes)
    Broken Sword 2 (without mpeg2 cutscenes)
    Touche: The Adventures of the Fifth Musketeer

Engines Skipped:
    Cinematique evo 2
    Drascula: The Vampire Strikes Back
    Igor: Objective Uikokahonia

Backend... sdl, HQ scalers, MT-32 emu
Looking for sdl-config... /usr/bin/sdl-config

Creating config.h
Creating config.mk
Post Reply