gnome-power-manager time remaining profile code

GNOME Power manager often sucks at predicting the amount of battery time you have left. To fix this, I've been working on a new time remaining profile class for gnome-power-manager. I'm using a self-adjusting discharge and charge profile that adjusts for the specific battery and computer that's being used, and also how it is being used. Why is this important?

  • BIOS's frequently lie to us pretty badly.
  • So called “smart” battery discharge chips are often really, really dumb.
  • Batteries sometimes have old or degraded cells that really don't hold much charge.
  • Batteries discharge faster if you are typing than if the computer idle. There's no point knowing how much time you have when idle, users want how much time they have when the computer is being used like normal.
  • Some batteries (like the OLPC or N800) don't give us much useful information and we have to be a bit clever.
  • Some BIOSes from Lenovo are REALLLLLY REALLLLLY BROKEN.
  • Sometimes machines with multiple batteries discharge in series or parallel, which completely change the way we calculate total capacity, and it's often pretty random when they change over.
  • We have a lot of floating point processing power available for some fairly advanced statistics when we are in userspace, rather than in the hardware or in the kernel.

So basically I suggest ignoring the battery capacity, and just watch how long in seconds it takes to change by each percentage point. Doing some clever rate calculations, and with enough duplicate data (which only takes 2 or 3 charge discharge cycles) the time is pretty easy to get. And, wow, it works – remarkably accurately, and more and more accurate with each charge/discharge cycle.


Sub-screenshot of data-profiling

Main problem: How do we prevent collecting bad data? Lots of things break the accurate profiling.

  • The OpenGL screensaver starting
  • The laptop screen doing DPMS off
  • Beagle doing a re-index while charging (large effect)
  • Lots of CPU load (like a kernel compile)
  • Large temperature variations.

So far I'm just rejecting any data collected during a load > 10%, or when the backlight is off, or while the session is idle. Ideally what I would like is are [Profile Start] and [Profile End] buttons that turn off all the power saving stuff and beagle/trackerd cache updates just until we have some sensible data, which we only need to do once. Ideas welcome on how to integrate this with any possible UI.

All of the new stuff is already in gnome-power-manager trunk, but some bits won't work unless you have pretty similar hardware to mine – plus it's got pretty minimal testing. The time remaining in the UI is currently all still based on the old method, but this new method will probably be selectable via gconf. So things are getting better.

One response to “gnome-power-manager time remaining profile code”

  1. Anonymous

    We don't need to worry about “real load” vs “normal load”. Over time (as measured in discharge cycles) load as compared to current charge converges on a norm unless the user is _deliberately_ using the machine less at some particular charge level (in which case, the smart-ass user gets the bad data that he deserves). It's not exactly an “average” per se, but that's fine — we really don't have a way to measure it anyway, nor a need.

Bad Behavior has blocked 2769 access attempts in the last 7 days.