mika76 / mamesaver

Mamesaver is a mame emulated screensaver - get all the good ol' games playing their demo modes while you procrastinate and enjoy!
https://mika76.github.io/mamesaver/
MIT License
37 stars 10 forks source link

Power management #23

Closed nullpainter closed 6 years ago

nullpainter commented 6 years ago

@andyvans and I were chatting the other day about power management, as it doesn't make much sense for MAME to keep running while the screen has gone to sleep. Apart from environmental concerns, my laptop's fan ends up sounding like a jet engine in the morning.

Unfortunately it appears that MAME prevents the screen (and computer!) from going to sleep so the obvious solution of interrogating power events won't work.

Instead, I have a PoC which:

  1. Reads the configured screen sleep time for AC and DC
  2. Determines whether the computer is on AC or DC
  3. Puts the screens to sleep and stops MAME when the sleep time is reached

What do you think? It's not the most beautiful approach, but it seems to work well. We can also extend this to read computer sleep configuration.

mika76 commented 6 years ago

Actually sounds great - I also use this on a laptop and it hits the fan hard. I wonder also, maybe MAME can be run as a lower priority thread? I wonder if that would have an effect?

mika76 commented 6 years ago

I wonder if some things mentioned here might also have an effect on how high the CPU usage is while MAME is running... https://wiki.mamedev.org/index.php/FAQ:Performance

MAME itself also has many options that can increase your speed:

  • Lower the sound quality. Try adding -sr 11025 to the command line, which will decrease sound playback quality and use less processor time. This mostly affects games that use discrete audio.
  • Disable the joystick and use the keyboard (-nojoy).
  • Use frameskip to speed up animation. Frameskip skips a certain number of frames per second, so your system does less work. Sometimes the trade-off is choppy animation; sometimes the difference is negligible. Experiment. While playing, press F8 / F9 to control frameskip; or set global frameskip in mame.ini. Some games don't benefit from frameskip though, for example the newer Williams bitmap graphics games or the Atari filled polygon games.

None of these things will help with switching off the screen but might help with the cpu usage while the screensaver is running...

mika76 commented 6 years ago

Interesting there seem to be other command line options which could be used maybe to make MAME not so intensive: https://docs.mamedev.org/commandline/commandline-all.html#core-performance-options

nullpainter commented 6 years ago

I think in my case, the 50 Chrome tabs and 3 VS instances may not be helping 😉

I'm less concerned about high CPU during screensaver operation - after all, those can all be set by the user in their mame.ini or in the screensaver configuration - and more about the screensaver not being a good citizen and doing what it ought with power saving.

I've turned my PoC into production-ready code and will send a PR over later today.

It's working really well and I've added logging to make its operation obvious. The only thing I noticed is that after switching from AC to DC and disconnecting external displays, the current MAME instance freezes. Not sure yet whether this is an us issue or a MAME issue. In any case, the sleep timer still runs so probably not something to worry too much about.

mika76 commented 6 years ago

Yeah true - all these can be set by the user - plus after playing with the settings none of them really helped - the fan still spun like mad - so not much use there...