[Captivate Android Development] glitterballs:
Nah, I'm reppin the Reorient_G gcc4.4.1 #10.

How I did this? I'm tinkering with a few things. Most of it is related to the knobs for the Ondemand CPU governor. Ondemand, in benchmarks, scores very, very closely to the Performance governor (max CPU freq. all the time), it scales up very rapidly. The way the Ondemand governor decides whether or not it should increase the CPU frequency is to measure the load to the CPU over some period of time called the sampling_frequency. If the CPU load is above a certain percentage of total capacity (at that frequency), it bumps up to the maximum frequency. So basically, quite often the CPU is ramping up to the maximum frequency to do nothing. Even when the phone is locked sometimes it will ramp up to 1000MHz, and really, how much do you care how fast your phone does things when you're not using it, right? So, a couple things you can do: for one, increase the sampling frequency from 40000us to some larger multiple of 40000.

Why 40000?

cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_transition_latency

So, taking a longer interval to measure the CPU load, you will quite often end up at less than 95% load during that period of time, and the CPU won't ramp up as often. Let's say you have to two time intervals, one is 95% the other 90%, your average load over 92.5%, which is below the up_threshoold, you don't scale up. The knob for changing the sampling frequency is at

/sys/devices/system/cpu/cpu0/cpufreq/ondemand/scaling_frequency

.

This actually works really nice with music, I can play FLAC and maintain 200MHz, and if things in gingerbread are like what they are for froyo, the CPU voltages at 100MHz and 200MHz are the same, and if they are different from froyo, I have to image still very close.

What's a "good" sampling frequency to choose? Well, that's up to you. I don't notice much latency until about a 200000us sampling_rate, 400000 is tolerable, but maybe that's only because I use Adw.Ex and can adjust the windows transition speed, it may be awful, or not even noticable on other launchers. Another thing I do is if I'm going to have music on for a while, I have a script I run before I lock the phone that is read_ahead_kb to some huge value so that the kernel doesn't have to wake up to pull stuff off the disk to put into memory, and the script will also set the sampling_rate to something like 800000us (.8s).

Another the the Ondemand governor is ignore niced processes when figuring how much CPU it needs to do the work. What nice means is another post, but the short version is that there are something that you can basically say "hey, I don't care how long it takes to get this done, give it a low priority on the CPU and don't count it toward the total CPU usage when we're deciding to go up or down". (BTW, has anyone seen a ps binary that shows nice value? The one is busybox is doesn't display it.) So on top of taking larger sampling intervals, you can also flat out ignore something things that would otherwise get you to the up_threshold and make your CPU clock speed go up.

The knob to ignore the nice load to the CPU is at

echo 1 > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/ignore_nice_load

You can also re-nice things like com.android.music (or whatever) to give it a lower priority and not trigger increases in CPU as much.

Finally, there's the powersave_bias feature. The powersave_bias let's you effectively limit the maximum CPU frequency. powersave_bias has a scale of 0-1000, and it attempts to reduce the maximum CPU speed on one-thousandth of what you set. Let's say you pick a powersave_bias of 200, it would request the maximum frequency * .2, or 1000MHz * .2 = 800MHz. But, if you set a powersave_bias of 100, the result would be a request of 900MHz which isn't available, so instead it would spend approximately even amounts of time at 800MHz and 1000MHz (900MHz on average). You set the powersave_bias at

echo "some number between 0 - 1000, but really, you should probably stick to 0 - 400" > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/powersave_bias

The nice thing about all these are that they are things you can tweak that everyone can tailor to how important extra battery or speed is to them.