Archive for June, 2010

how to improve user performance on android phones

Monday, June 28th, 2010

I am not responsible if you mess your phone up.  Seriously.

The following requires that you root your phone.  That is not covered here, however for the Droid you can update your 2.0.1 phone with this update.zip.

Connect to your phone with adb shell, then:

$ su
# mount -o remount,rw /system
# echo 'kernel.sched_latency_ns = 600000' >> /etc/sysctl.conf
# echo 'kernel.sched_min_granularity_ns = 400000' >> /etc/sysctl.conf
# echo 'kernel.sched_features = 24188' >> /etc/sysctl.conf
# mount -o remount,ro /system
# sysctl -p
kernel.sched_latency_ns = 600000
kernel.sched_min_granularity_ns = 400000
kernel.sched_features = 24188
# exit
$ exit

Now your phone will behave a lot better.  To explain what those settings do:

Changing sched_features to 24188 disables some annoying CFS features (GENTLE_FAIR_SLEEPERS and NORMALIZE_SLEEPERS) that are stupid even on the desktop.  The other two crank the timeslice length down to 0.6ms/0.4ms.

What about BFS you say? Well BFS does not appear to perform very well on Android, and Android’s legitimate use of cgroups does not work on BFS.  However, the settings that the sysctls above change make CFS behave a lot more like BFS.

At any rate, after making these changes, my Motorola Milestone has no problems keeping up with another android phone I have (the HTC Incredible).

What does this mean?

This means that all the hype about JIT in Android 2.2 being the biggest possible source of performance improvement is a load of crap.  JIT will improve CPU-bound tasks, but it will not improve the interactivity of the underlying OS, which is what people are really complaining about.

This also proves that overclocking your phone is stupid and dangerous.  Just do the above and you won’t be damaging your phone’s hardware.  You will also get a much more noticeable performance boost out of this than you would out of overclocking your phone.

I mean, my Milestone is actually usable now.  It’s 550mhz and it has absolutely no problems keeping up with the Incredible’s 1000mhz CPU.  Just think about that.  The HTC’s CPU is being put to waste due to the way that the scheduler allocates timeslices.  If you disable the GENTLE_FAIR_SLEEPERS option, CFS becomes a very good scheduler for android, as it allows for sub-1ms timeslice deadlines.

Update: Disabling NORMALIZE_SLEEPERS on Android 1.6/2.0/2.1 is a good idea.