Wednesday, October 5, 2011

CPU Governors

I've been tinkering around with cpu governors quite a bit in my Android kernels.  I believe governors are a single most effective way to improve or diminish the "user perceivable" performance of the device.

Here's my personal take on governors that are included in stock and other custom kernels:

performance - max speed all the time
powersave - lowest speed all the time
conservative - slow ramp-up

The next few get a bit more complex. ondemand, interactive, and smartass all try to pretty much do the same thing: perform well and power efficient. But the way they approach their goals are very different (ie. their algorithms are very different).

1) ondemand - been in linux for a long time and we got really smart linux kernel developers working on it and the code gets reviewed by really smart people. At the same time this governor is really designed to work on desktops, servers, phones, etc - a universal solution.
2) interactive - developed by CM (I think), tuned for performance. Instead of sampling at every interval like ondemand, it determines how to scale up when cpu comes out of idle.
3) smartass - developed by erasmux for his android kernel. Popular for its ability to use android's onboard suspend mechanism to keep the phone below a certain clock speed when screen is turned off. Also does slow ramp-up like the conservative governor.

Instead of the above, here are the three governors that I include in my custom kernels:

  • interactiveX - it's the interactive governor from CM, but I added suspend/wake logic so when the phone screen is off it runs at below 400Mhz. Also, I modified its code some more to minimize unnecessary cpu spikes above a certain threshold if kernel is heavily overclocked. (Most devices are unstable above a certain speed when it's heavily overclocked, and it's the quick jump to top speed that usually locks up the phone.)
    I like this governor because it's simple and fast.
  • ondemandX - ondemand governor code from latest linux (3.0 at the moment) source *plus* the suspend/wake logic described above. No further optimization is done.
  • smartass - smartass code from erasmux, but I wasn't happy with its performance so I tuned it for quicker ramp up in speed. It has the same suspend/wake logic as ondemandX, and similar stability optimizations as interactiveX. (update: smartassV2 is new and currently I include the v2 in my kernels without optimizing further).